Will git branch -u (or --set-upstream-to) lose the tracking information of all existing remote tracking branches?

I was in my “workshop” branch when I thought about creating a new branch and did it by:

$ git checkout -b od_newstructure Switched to a new branch 'od_newstructure' 

I made a few changes and added this new branch to the remote one and started tracking

 $ git commit $ git branch -u origin/od_newstructure Branch od_newstructure set up to track remote branch od_newstructure from origin. $ .. some other work including git pull and git push 

Now I wanted to return to the master. Therefore i did

 git checkout master Switched to branch 'master' 

But then the master did not seem to track the origin / master anymore!

 $ git branch -vv * master d1db2e3 Subdivided into several namespaces od_newstructure d1db2e3 [origin/od_newstructure] Subdivided into several namespaces 

It has also been checked with git pull

 $ git pull There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details 

My question is: why did previous tracking branches lose tracking information when I switched to a new tracking branch? Is this default behavior and sound? Should I add upstream git branch -u every time I switch to the tracking branch?

+4
source share

All Articles