git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: tracking repository

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 16, 2008, 02:42 UTC
Message-ID
<7vabkzmltc.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<frh8dg$t9j$1@ger.gmane.org>
kenneth johansson <ken@kenjo.org> writes:
Show 7 quoted lines
> 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.

Previous: kenneth johanssonNext: kenneth johansson
Message 2 of 16 in “tracking repository”
  1. kenneth johanssonMar 15, 2008
  2. Junio C HamanoMar 16, 2008
  3. kenneth johanssonMar 16, 2008
  4. Junio C HamanoMar 16, 2008
  5. Daniel BarkalowMar 16, 2008
  6. Junio C HamanoMar 16, 2008
  7. Daniel BarkalowMar 16, 2008
  8. Junio C HamanoMar 16, 2008
  9. Junio C HamanoMar 16, 2008
  10. Daniel BarkalowMar 16, 2008
  11. Junio C HamanoMar 17, 2008
  12. Junio C HamanoMar 17, 2008
  13. Daniel BarkalowMar 17, 2008
  14. Daniel BarkalowMar 17, 2008
  15. Junio C HamanoMar 17, 2008
  16. Daniel BarkalowMar 17, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.