repo - Why doesn't my Git status show me whether I'm up-to-date with my remote counterpart? -


i have tried making changes, pushed github. computer, fetched changes. when git status, reports this:

on branch mytestbranch nothing commit, working directory clean 

this strange because i'm there changes fetched. did merge changes fetched!

in fact when went on friend's computer , did git status, see this:

your branch behind 'origin/mytestbranch' 1 commit, , can fast-forwarded. 

but why weren't git reporting origin/mytestbranch how many commits ahead or whether branch up-to-date origin/mytestbranch?

my guess @ point (i'm still waiting git branch -vv or git rev-parse --symbolic-full-name "@{u}" results) not have origin/mytestbranch set upstream mytestbranch.

to set branch upstream current branch, use:

git branch --set-upstream-to upstream1

which in case expands to:

git branch --set-upstream-to origin/mytestbranch 

to remove upstream setting, use git branch --unset-upstream.

the presence or absence of upstream setting affects whether git status can tell if ahead and/or behind, , whether git merge , git rebase can job no additional parameters. it's convenience setting.

normally upstream set automatically when first check out branch having git checkout create based on remote-tracking branch. instance, on first git clone, git runs, @ end, equivalent of:

git checkout master 

even though have no master yet. git discovers have origin/master (and no other remote/master there no question which remote use), , equivalent of:

git checkout -b --track master origin/master 

which creates local master pointing same commit remote-tracking branch origin/master, , setting origin/master upstream master, in 1 big do-what-i-mean fell swoop.

when create new local branch , have not yet pushed upstream, there no origin/whatever remote-tracking branch local branch track.2 in case, have set upstream manually, or use git push -u ...: -u tells git push run git branch --set-upstream-to (although it's built in c code, @ point).


1if you're stuck ancient git (pre-1.8.0) must use git branch --set-upstream, tricky right, or git config, tricky right. if @ possible, upgrade modern git version.

2the set of words here—nouns branch, nouns adjectives local branch , remote-tracking branch, , verbs set-upstream-to , gerunds tracking—is rather unfortunate. git terminology, put in nice short memorable anglo-saxon way instead of polysyllabic neologistic phraseology, sucks rocks.3

3or other anglo-saxon kick-ass word of choice.