Git: what exactly causes remote branches to update? -


according pro git (3.5):

[remote branches are] local branches can’t move; they’re moved      automatically whenever network communication. 

however, doesn't seem correct in practise. i've arrived @ situation

 branch ahead of 'origin/branch-x' 23 commits. 

but haven't done commits, fetched /pulled modifications other people have pushed origin. if statement of pro git correct expect remote branch same local one, since every fetch or pull communication origin.

what exact operations update remote branches?

i suspect issue might rooted in special twist git pull has in semantics — let's cite git pull manual:

some short-cut notations supported.
...
parameter <ref> without colon equivalent <ref>: when pulling/fetching, merges <ref> current branch without storing remote branch anywhere locally

this means when do

git pull 

or

git pull origin 

(which rely on branch.<name>.remote , branch.<name>.merge — in latter case — configuration variables) branches remote repo has fetched , remote branches in local repository updated accordingly.

but when git pull origin branch-x, objects of branch "branch-x" in repo "origin" fetched1, no remote branch updated in local repo, , fetched tip object merged checked out branch.

so fix situation run git fetch origin , have remote branches updated. might want consider reading this blog post better idea of why git pull not precise equivalent git fetch + git merge in possible cases.

another way fix situation origin/branch-x remote branch git push origin branch-x assuming local branch-x set track origin/branch-x — happens because when push tracking branch git knows receiving branch in remote repo looks branch you've pushed , it's sane thing update matching remote branch. if not feel comfortable these concepts (remote branches vs tracking branches) start reading this part of book.


1 well, objects missing in local repository fetched.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -