The workflow I have on my current project has me constantly repeating the commands:
git checkout master ; git pull ; git checkout (working branch) ; git rebase ; git push origin (working branch name)
This was getting a bit tedious. This link: http://stackoverflow.com/questions/12776015/git-alias-with-variables-not-working-as-expected-pathspec-did-not-match-any-fil
Kindly shows how to use variables in a git alias.
This way we can set up an alias to do the whole messy command chain for us. But first, to make pushing a bit easier, follow the directions on this post:
And then make a new alias in your ~/.gitconfig:
superupdate = !CURRENTBRANCH=$(git symbolic-ref --short HEAD) && echo Currently on $CURRENTBRANCH - switching to master && git checkout master && git pull && echo Going back to $CURRENTBRANCH && git checkout "$CURRENTBRANCH" && git rebase master && git push
If you want to get really cool after this you can add a shell script to open a pull request in thew browser (this code is mac-specific, but surely can be adapted to any platform.) I'm using ZSH as my shell here.
alias gitpullrequest="git superupdate; open -a Google\ Chrome \"https://github.com/REPOSITORY/pull/new/BRANCH\""
You've got to replace REPOSITORY and BRANCH with the appropriate URL pieces. But once that's done, all should work dandy!