Last active
August 29, 2015 13:56
-
-
Save thejsj/9004070 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# A simple commit shell script | |
# Instructions: | |
# source ./commit.sh LOCAL_BRANCH_NAME 'COMMIT_MESSAGE' | |
# | |
# Example: | |
# source ./commit.sh staging 'Adding some cool files to this repo' | |
# | |
# Input Vars | |
LOCAL_BRANCH=$1 | |
if [ "$LOCAL_BRANCH" != "" ]; then | |
echo "Local Branch: ${LOCAL_BRANCH}" | |
# change from your local branch to the master branch | |
git checkout master | |
# pull down the latest master brach (it may have changed since you began work) | |
git pull origin master | |
# change back to your local branch (where your changes are being stored) | |
git checkout ${LOCAL_BRANCH} | |
# rewind all of the changes that you made to your local branch back to it's latest master | |
# and then update its master to the new latest (pulled down in the previous step) lastly reapply your changes overtop of the new master branch | |
git rebase master | |
#switch back to the master branch | |
git checkout master | |
# merge your local branch into the local master branch | |
git merge ${LOCAL_BRANCH} | |
# send the updated master branch into the internets | |
git push origin master | |
# check your local branch out again so you are ready to code your next feature etc. | |
git checkout ${LOCAL_BRANCH} | |
echo "" | |
echo -e "\033[33;32mCommit to 'master' from '${LOCAL_BRANCH}' done.\033[0m" | |
echo -e "Check above for any errors." | |
else | |
echo -e "\033[33;31mAborting.\033[0m" | |
echo "No 'local' branch specified" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment