If I’m working on a branch and then realize I need to merge another branch into mine here is my current workflow (for this example lets say that I’m working on my-branch and want to merge in master):
git stash git checkout master git pull git checkout my-branch git merge master git stash pop
Is there a way in git to pull a branch other than the currently checked out one, or is there a better way to do this?
For example, here’s what I’d like to be able to do (again lets say I’m on my-branch and want to merge in
git pull master git merge master
The git-pull man page says that a git pull is just a get fetch followed by a git merge, so is there a way to do the merge part of the git pull on a branch other than the one that’s currently checked out?
Or is what I’m asking for just not possible?
I found an incantation that worked for me:
git fetch origin master:master
then (if you want to merge right away):
git merge master
I was really surprised how hard it was to find an answer to this since it seems like it would be a common use case.