git pull --all does not update HEAD for the branches you're not on

published Jun 16, 2015 03:50   by admin ( last modified Jul 21, 2015 11:04 )

Summary

To merge in changes from "other_branch", do this:

git pull --all
git merge origin/other_branch

Longer story

I continuously need to merge in changes from a branch that I have branched off of. Sometimes I do it by switching over to that branch locally, do a pull, and then switch back to mine and do a

git merge other_branch

That works fine. But sometimes I have tried to remain on my branch and do a

git pull --all

followed by a a

git merge other_branch

But that won't work! Why?

"git pull --all" does indeed fetch all tracked remotes and updates them, but only merges new updates locally on your current branch. So even if other branches are updated locally, HEAD hasn't moved in them and from merge's point of view the updates aren't there.

This ought to solve the problem:

git merge origin/other_branch

currently untested by me.

Update: Now tested by me. It doesn't work.... unless you pull first! So this is the way it should look:

git pull --all
git merge origin/other_branch