Subject: Re: tracking repository

From: Junio C Hamano <[email-masked]>
Date: Sat, 15 Mar 2008 19:42:23 -0700

kenneth johansson <[email-masked]> writes:

> This works great and it will track all changes in the remote repositories 
> without me having to worry about it aborting due to merge issues with my 
> local branch or remote  doing rebase on some branch.
>
> The problem is that it is useless :( I can't find any way to use a 
> repository with only remotes in it. Is there a way to make a clone of a 
> remote branch in a repository ??

Usually a clone with a work tree ("git clone $elsewhere") is configured to
keep copies of branches at the remote in remotes/origin in order to track
them, and that is done by having this in its .git/config:

	[remote "origin"]
		url = $elsewhere
		fetch = +refs/heads/*:refs/remotes/origin/*
	[branch "master"]
        	remote = origin
                merge = refs/heads/master

This lets you to have your own work on your own "master", and have changes
on the other end merged when you "git pull" from there, while keeping
track of other branches on the other end in remotes/origin/ namespace.

You do not want to have any of your own work in this repository, however,
so there is no reason to separate the remote ones in remotes/origin/
namespace.  You would want "mirroring".

You can have in your $GIT_DIR/config something like this:

        [remote "origin"]
		url = $elsewhere
                fetch = +refs/heads/*:refs/heads/*

You can edit the configuration file yourself to read like above, and then
"git fetch" will keep a copy of remote "master" branch in your local
"master" (and similarly to all the branches over there).

Modern git allows this setup via "git remote add --mirror"; it is merely a
convenience wrapper and it is perfectly fine to edit the configuration
file yourself without using it.