I work on a project that has 2 branches, A and B. I typically work on branch A, and merge stuff from branch B. For the merging, I would typically do:
git mer
In your case you can use
git fetch origin branchB:branchB
which does what you want (assuming the merge is fast-forward). If the branch can't be updated because it requires a non-fast-forward merge, then this fails safely with a message.
This form of fetch has some more useful options too:
git fetch :
Note that
can be a local repository, and
can be a tracking branch. So you can update a local branch, even if it's not checked out, without accessing the network.
Currently, my upstream server access is via a slow VPN, so I periodically connect, git fetch
to update all remotes, and then disconnect. Then if, say, the remote master has changed, I can do
git fetch . remotes/origin/master:master
to safely bring my local master up to date, even if I currently have some other branch checked out. No network access required.