git: setting a single tracking remote from a public repo.

Posted by Gauthier on Stack Overflow See other posts from Stack Overflow or by Gauthier
Published on 2010-06-08T15:48:18Z Indexed on 2010/06/09 7:52 UTC
Read the original article Hit count: 239

Filed under:
|
|
|

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:

  1. git fetch int gets me all the branches of int into remote branches. This can get messy since int might have hundreds of branches.

  2. git fetch int master gets me the commits, but no ref to it, only FETCH_HEAD. No remote branch either.

  3. git fetch int master:new_master works but I don't want a new name every time I update, and no remote branch is setup.

  4. git pull int master does 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.

  5. 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 -v does 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.

  6. 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.

© Stack Overflow or respective owner

Related posts about git

Related posts about remote