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

[PATCH v2 0/3] Teaching "git push" to map pushed refs

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 5, 2013, 01:27 UTC
Message-ID
<1386206849-6503-1-git-send-email-gitster@pobox.com>
In-Reply-To
<1386117594-22062-1-git-send-email-gitster@pobox.com>

The 'master' refspec in "git fetch origin master" used to mean "We grab their 'master' branch, but we do not store it in any of our remote-tracking branches." but in modern Git, the remote-tracking branch that would receive updates from 'master' with a corresponding "git fetch origin" (without any specific refs on the command line) is updated. Updating the same refs/remotes/origin/master with

	git fetch origin
	git fetch origin master
avoids surprises.

However, we did not have a similar refspec mapping on the push side. This three-patch series does just that. It would help triangular workflow by making these two:

	git checkout master && git push origin
	git push origin master

update the same ref at the 'origin'. It also would help those who need to emulate a fetch run on mothership from satellite with a push run on satellite into mothership (due to e.g. network connectivity issues).

The second round avoids instantiating the remote and the list of local heads until the very last minute when they are actually needed (the change is in the second patch).

Junio C Hamano (3):
  builtin/push.c: use strbuf instead of manual allocation
  push: use remote.$name.push as a refmap
  push: also use "upstream" mapping when pushing a single ref
 Documentation/git-push.txt |  9 +++--
 builtin/push.c             | 84 ++++++++++++++++++++++++++++++++++------------
 remote.c                   |  8 ++---
 remote.h                   |  2 ++
 t/t5516-fetch-push.sh      | 75 +++++++++++++++++++++++++++++++++++++++++
 5 files changed, 150 insertions(+), 28 deletions(-)
-- 
1.8.5.1-402-gdd8f092
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 8 in “Teaching "git push" to map pushed refs”
  1. 0/3 Teaching "git push" to map pushed refsJunio C Hamano, Dec 4, 2013
  2. 1/3 builtin/push.c: use strbuf instead of manual allocationJunio C Hamano, Dec 4, 2013
  3. 2/3 push: use remote.$name.push as a refmapJunio C Hamano, Dec 4, 2013
  4. 3/3 push: also use "upstream" mapping when pushing a single refJunio C Hamano, Dec 4, 2013
  5. 0/3 Teaching "git push" to map pushed refsJunio C Hamano, Dec 5, 2013
  6. 1/3 builtin/push.c: use strbuf instead of manual allocationJunio C Hamano, Dec 5, 2013
  7. 2/3 push: use remote.$name.push as a refmapJunio C Hamano, Dec 5, 2013
  8. 3/3 push: also use "upstream" mapping when pushing a single refJunio C Hamano, Dec 5, 2013

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.