How to 'git pull' into a branch that is not the current one?
This is answered here: Merge, update, and pull Git branches without using checkouts
# Merge local branch foo into local branch master,
# without having to checkout master first.
# Here `.` means to use the local repository as the "remote":
git fetch . foo:master
# Merge remote branch origin/foo into local branch foo,
# without having to checkout foo first:
git fetch origin foo:foo
Straightforward: Updating from a remote branch into a currently not checked-out branch master:
git fetch origin master:master
where origin is your remote and you are currently checked out in some branch e.g. dev.
If you want to update your current branch in addition to the specified branch at one go:
git pull origin master:master
As it turns out, the answer is deceptively simple:
$ git fetch # Update without changing any files
$ git branch -d master # Remove out-of-date 'master' branch
$ git checkout --track origin/master # Create and check out up-to-date 'master' branch
This allows you to update the master
branch without switching to it until after it has been updated.