I was under the assumption that:
git fetch origin
would update all the remote branches:
remotes/origin/master
remotes/origin/dev
etc.
but it turns out that doesn't seem to be the case and I can't figure out how these branches stay up to date, if it's not the case.
how can I make sure my local remote branches are up to date? perhaps I will have better luck with:
git fetch origin master:master
?
Generally, git fetch origin
will update all the remote-tracking names under origin/*
. Under what conditions are you not seeing this occur? There are two common cases in modern Git:
A single-branch clone maps one upstream branch to one remote-tracking name. If that's not what you want, avoid single-branch clones (or transform them into normal clones).
Running git fetch origin master
, for instance, limits the update to updating only origin/master
, even if, say, dev
on origin
has new commits that would update origin/dev
if you had run git fetch origin
instead of git fetch origin master
.
That second case is driven all the time by git pull
, if you use it. (I recommend avoiding git pull
in favor of separate fetch and second-command, rebase or merge as desired.)
One last case is common in Git versions predating 1.8.2, in which git fetch origin master
fails to update even origin/master
, for instance. The solution to this is to upgrade to a modern Git.