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

[PATCH] Set up remotes/origin to track all remote branches.

From
Junio C Hamano <junkio@cox.net>
Date
Nov 6, 2005, 09:23 UTC
Message-ID
<7v1x1u1652.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.64.0511041745480.25300@iabervon.org>
Daniel Barkalow <barkalow@iabervon.org> writes:
Show 12 quoted lines
> On Thu, 3 Nov 2005, Junio C Hamano wrote:
>
>> My "guinea pig" repository has this in $GIT_DIR/remotes/origin:
>> 
>>         URL: git://git.kernel.org/pub/scm/git/git.git
>>         Pull: master:origin
>>         Pull: +pu:pu
>>         Pull: maint:maint
>
> Shouldn't approximately this be what git-clone sets up for you? If it's 
> getting those heads initially, it should keep the information for future 
> use. The only thing it wouldn't know would be the "+" on pu.

I think this makes sense, and especially so, once we later change the default behaviour of 'git clone' to clone but rename the remote refs to somewhere else.

-- >8 -- cut here -- >8 --

This implements the idea Daniel Barkalow came up with, to match the remotes/origin created by clone by default to the workflow I use myself in my guinea pig repository, to have me eat my own dog food.

We probably would want to use either .git/refs/local/heads/* (idea by Linus) or .git/refs/heads/origin/* instead to reduce the local ref namespace pollution.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 Documentation/git-clone.txt |    3 ++-
 git-clone.sh                |   12 ++++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

applies-to: 9cc3928769f8f4e3597fa446321112c0568514df a0b45ee2b1362d664cca2d81f2915ed3b903b252

diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt
index cbd83f3..fefd298 100644
--- a/Documentation/git-clone.txt
+++ b/Documentation/git-clone.txt
@@ -25,7 +25,8 @@ This is to help the typical workflow of 
 remote `master` branch.  Every time `git pull` without argument
 is run, the progress on the remote `master` branch is tracked by
 copying it into the local `origin` branch, and merged into the
-branch you are currently working on.
+branch you are currently working on.  Remote branches other than
+`master` are also added there to be tracked.
 
 
 OPTIONS
diff --git a/git-clone.sh b/git-clone.sh
index 1adf604..4fdd652 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -202,8 +202,16 @@ then
 		mkdir -p .git/remotes &&
 		echo >.git/remotes/origin \
 		"URL: $repo
-Pull: $head_points_at:origin"
-		cp ".git/refs/heads/$head_points_at" .git/refs/heads/origin
+Pull: $head_points_at:origin" &&
+		cp ".git/refs/heads/$head_points_at" .git/refs/heads/origin &&
+		find .git/refs/heads -type f -print |
+		while read ref
+		do
+			head=`expr "$ref" : '.git/refs/heads/\(.*\)'` &&
+			test "$head_points_at" = "$head" ||
+			test "origin" = "$head" ||
+			echo "Pull: ${head}:${head}"
+		done >>.git/remotes/origin
 	esac
 
 	case "$no_checkout" in
---
0.99.9.GIT
Previous: Junio C Hamano
Message 6 of 6 in “Trying to Update All Heads of a Repository”
  1. Jon LoeligerNov 4, 2005
  2. Linus TorvaldsNov 4, 2005
  3. Junio C HamanoNov 4, 2005
  4. Daniel BarkalowNov 4, 2005
  5. Junio C HamanoNov 5, 2005
  6. Set up remotes/origin to track all remote branches.Junio C Hamano, Nov 6, 2005

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.