-
-
Save RickMoynihan/95220 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
# This function updates the current branch with the latest changes from the | |
# origin repository. The master branch is checked out, a git pull is performed, | |
# the original branch is checked out again, and then the changes from master | |
# are rebased back into the branch. | |
# | |
# Essentially, the following steps are performed. The command is smart enough | |
# to do the right thing when the current branch _is_ the master branch. | |
# | |
# git checkout master | |
# git pull --rebase | |
# git checkout $branch | |
# git rebase master | |
# | |
function gitu { | |
branch=`gitb` | |
if [ "$branch" != "master" ]; then | |
git checkout master | |
fi | |
git pull --rebase | |
if [ "$branch" != "master" ]; then | |
git checkout "$branch" | |
git rebase master | |
fi | |
} | |
# This function pushes the changes from the current branch up to the origin | |
# repository. The master branch is checked out and the changes from the | |
# original branch are rebased into the master branch. After this, all changes | |
# are pushed to the origin repository. The original branch is checked out | |
# again. | |
# | |
# Essentially, the following steps are performed. The command is smart enough | |
# to do the right thing when the current branch _is_ the master branch. | |
# | |
# git checkout master | |
# git rebase $branch | |
# git push | |
# git checkout $branch | |
# | |
function gitp { | |
branch=`gitb` | |
if [ "$branch" != "master" ]; then | |
git checkout master | |
git rebase "$branch" | |
fi | |
git push | |
if [ "$branch" != "master" ]; then | |
git checkout "$branch" | |
fi | |
} | |
# This function calls the "gitu" and the "gitp" functions in succession. This | |
# pulls in changes from the master branch to the current branch, and then | |
# pushes all changes from the current branch up to the origin repository. This | |
# combination of commands keeps the master branch revision history nice and | |
# linear. | |
# | |
function gitup { | |
gitu | |
gitp | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment