threads / discuss / 21978

adding additional remote refs to a remote repo

Subject: adding additional remote refs to a remote repo

## tl;dr

2 messages between Dec 17, 2009 and Dec 17, 2009.

replies: 1people: 2as markdown or json

Peter Petrakis· Dec 17, 2009, 17:43 UTC · lore

I'm setting up a remote repo to aggregate some development which spans multiple git trees. So I have a bare repo setup using gitosis that I can happily commit to. I've added the entries directly to the config on the server...

-sh-3.2$ ls
branches  config  description  git-daemon-export-ok  HEAD  hooks  info
 objects  refs
-sh-3.2$ cat config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = true
[remote "drbd-8.2"]
        url = git://git.drbd.org/drbd-8.2.git
        fetch = +refs/heads/*:refs/remotes/drbd-8.2/*

but when I clone the repo, the remote doesn't show up. What am I doing wrong? I can easily add the remotes in my local copy and work with the product. The problem is that we're tracking this upstream project and need to manage multiple versions of it to serve past releases. So in my case the branches will directly track the upstream development + any changes we need and then be merged into master.

For example in my local clone.
[remote "drbd-8.2"]
        url = git://git.drbd.org/drbd-8.2.git
        fetch = +refs/heads/*:refs/remotes/drbd-8.2/*
[branch "drbd-8.2.7-merge-branch"]
        remote = drbd-8.2
        merge = refs/heads/master

Now if I push this drbd-8.2.7-merge-branch to the central repo, the next guy won't know for sure what this was tracking. I also don't want to have to 'add remote ...' every time I clone a new copy. Thanks.

Peter
Junio C Hamano· Dec 17, 2009, 18:19 UTC · re: Peter Petrakis · lore

Re: adding additional remote refs to a remote repo

Peter Petrakis <peter.petrakis@gmail.com> writes:
> Now if I push this drbd-8.2.7-merge-branch to the central repo, the next
> guy won't know for sure what this was tracking. I also don't want to
> have to 'add remote ...'  every time I clone a new copy. Thanks.

The kind of information you listed above are kept in $GIT_DIR/config of each repository. This file is kept private to each repository, i.e. not cloned, fetched or pushed across repositories [*1*].

This is a deliberate design decision.
 - The file records mostly personal preferences, e.g. how user works with
   his branches in the repository, if the integration is done via rebase
   instead of merge, how the output is colored, etc.  Your colleagues can
   and will use branches other than the ones that may be publicly shared
   (like drbd-8.2.7-merge-branch), and how they use their private branches
   is not something you want to dictate nor interfere with.
 - The [remote "foo"] sections and friends (e.g. [branch "bar"]) in the
   "$GIT_DIR/config" in that bare repository you created specifies how
   that particular repository interacts with the remote named "foo" and
   how branch "bar" is integrated with other things.  These may not
   necessarily match, and if you are using it as a middleman repository
   between your developers and the project upstream, they will in general
   not match, the setting the developer repositories want to use.  This
   should be obvious if you think about where remote.origin.url should
   point at.  In the middleman repository, you would want "git fetch"
   without "origin" to slurp from the upstream and in the developer clones
   of this repository, you would want to "git fetch" to update from this
   middleman repository.
 - The file can has pointers to external programs to be used as filters;
   blindly copying it upon clone has security implications as well.
[Footnote]

*1* Often people use README-like document in-tree to tell developers about the specific settings the project wants them to use (i.e. "how to work with this project"), together with coding styles, submission guidelines, etc., that are not tied to the use of git.

← back to recent threads