I am confused with remote branches.
My local repo:
(local) ---A---B---C-master
My remote repo (called int):
(int) ---A---B---C---D---E-master
What I want to do is to setup the local repo's master branch to follow that of int. Local repo:
(local) ---A---B---C---D---E-master-remotes/int/master
So that when int changes to:
(int) ---A---B---C---D---E---F-master
I can run git pull from the local repo's master and get
(local) ---A---B---C---D---E---F-master-remotes/int/master
Here's what I have tried:
- git fetch intgets me all the branches of int into remote branches. This can get messy since int might have hundreds of branches.
- git fetch int mastergets me the commits, but no ref to it, only- FETCH_HEAD. No remote branch either.
- git fetch int master:new_masterworks but I don't want a new name every time I update, and no remote branch is setup.
- git pull int masterdoes what I want, but there is still no remote branch setup. I feel that it is ok to do so (that's the best I have now), but I read here and there that with the remote setup it is enough with- git pull.
- git branch --track new_master int/master, as per http://www.gitready.com/beginner/2009/03/09/remote-tracking-branches.html . I get "not a valid object name: int/master".- git remote -vdoes show me that int is defined and points at the correct location (1. worked). What I miss is the int/master branch, which is precisely what I want to get.
- git fetch in master:int/master. Well, int/master is created, but is no remote.
So to summarize, I've tried some stuff with no luck. I would expect 2 to give me the remote branch to master in the repo int.
The solution I use now is option 3.
I read somewhere that you could change some config file by hand, but isn't that a bit cumbersome?
The "cumbersome" way of editting the config file did work:
[branch "master"]
    remote = int
    merge = master
It can be done from command line:
$ git config branch.master.remote int
$ git config branch.master.merge master
Any reason why option 2 above wouldn't do that automatically?
Even in that case, git pull fetches all branches from the remote.
 
    