Last active
April 10, 2017 23:50
-
-
Save pestilence669/9a0f19b90d16b4240537 to your computer and use it in GitHub Desktop.
Fetch upstrem master and rebase
This file contains hidden or 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/bash | |
| # vim: set ts=4 sw=4 noet: | |
| # get current checked out branch | |
| B=`git rev-parse --abbrev-ref HEAD` | |
| if [ $? -ne 0 ]; then # problem, likely not a git repo | |
| exit -1 # leave whatever error occurred alone | |
| fi | |
| # sync from the upstream origin | |
| git fetch upstream | |
| # switch to master, if we aren't already there | |
| if [ $B != "master" ]; then | |
| git co master | |
| fi | |
| git pull --rebase upstream master || exit -1 | |
| # switch back and rebase, if we didn't have master checked out | |
| if [ $B != "master" ]; then | |
| git co $B | |
| git rebase master $B | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment