Skip to content

Instantly share code, notes, and snippets.

@OneGneissGuy
Forked from cacycleworks/git_update.sh
Created September 11, 2020 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OneGneissGuy/b7ee7e1ae68e8084c7098f017609fdf3 to your computer and use it in GitHub Desktop.
Save OneGneissGuy/b7ee7e1ae68e8084c7098f017609fdf3 to your computer and use it in GitHub Desktop.
Simple sh script to automate a git update
#!/bin/sh
if [ $# != 2 ]; then
echo "\nchris k's git update automater sh script. Edit to put a bunch of \`git add blah'"
echo "lines in the body then evoke with the branch name and commit description\n"
echo "Usage: $0 <branch_name> <\"Description of update\">\n"
echo " branch_name: the name of the git branch to be created"
echo " Description: Text for: git commit -m \"Description of update\""
echo ""
echo "Example:"
BRANCH="core_override"
MESSAGE="Edited core files to fix system.log warnings"
echo " $0 $BRANCH \"$MESSAGE\"\n\nWhich then executes the following:\n"
echo "git checkout -b $BRANCH"
echo "git add /app/code/local/Mage/some/buggy/core/file"
echo "commit -m \"$MESSAGE\""
echo "git checkout master"
echo "git merge --no-ff $BRANCH"
echo "git branch -d $BRANCH"
echo "git push origin master"
echo "\n"
exit
fi
BRANCH=$1
MESSAGE=$2
git checkout -b $BRANCH
echo "Adding the changed files you edited to put in this script:"
# ADD THE "git add files" below:
# take the output from `git status' then do a search and replace on the leading
# `# modified: ' to change to `git add'
# of this kind of line:
# # modified: app/code/local/Amasty/Base/Block/Store.php
# to then become:
# git add app/code/local/Amasty/Base/Block/Store.php
git add /app/code/local/Mage/some/buggy/core/file
git commit -m "$MESSAGE"
git checkout master
git merge --no-ff $BRANCH
git branch -d $BRANCH
git push origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment