Pull for another Git branch without switching
I was able to pull changes from origin/master
into master
while working in another branch by using this command:
git fetch origin master:master
For a deeper dive into what's going on, check out the excellent answer to this Stack Overflow question. The main take-away for me was that this command only works for a fast-forward merge.
You can use git stash
before checking out master and pulling, and after checking out live again use git stash pop
(or if your git is older, git stash apply
and git stash clear
assuming you haven't stashed anything else)