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

Suggestion: git fetch <remote> <branch> to update remote-tracking branch

From
Antony Male <antony.male@gmail.com>
Date
Mar 5, 2012, 16:45 UTC
Message-ID
<4F54EDC1.80608@gmail.com>
Hi all,

First off, this is a very tentative suggestion. It would result in a slight change to established behaviour, which I'm well aware could be a Bad Thing(tm). However, I was encouraged by a number of people on #git to make it anyway, so here goes.

The issue is this: the two-argument form of 'git fetch' (e.g. 'git fetch <remote> <branch>') fetches the named ref into FETCH_HEAD, but does not update the related remote-tracking branch. While this is intuitive behaviour when <remote> is a URL, we see a lot of git beginners attempting to run 'git fetch origin branch' and being confused when origin/branch isn't updated. Similarly, 'git pull origin master' will, in a simple case, fast-forward the local master but not origin/master.

My suggestion, therefore, is to modify the behaviour of 'git fetch' such that 'git fetch <remote> <branch>' will update both FETCH_HEAD and the relevant remote-tracking branch, when <remote> is the name of a configured remote and <branch> contains only the src part of the refspec. The behaviour would not change when <remote> was a URL or path, or when a <src>:<dst> refspec was used.

Of course, it would be desirable to be able to replicate the existing behaviour. Currently, I don't have any good suggestions, although there may be an existing trick I'm missing. Possible suggestions might be 'git fetch <remote> <branch>:FETCH_HEAD' or 'git fetch <remote> <branch>:', or maybe a new flag?

What do people think?

Many thanks for your time and consideration, Antony Male

Next: Junio C Hamano
Message 1 of 3 in “Suggestion: git fetch <remote> <branch> to update remote-tracking branch”
  1. Antony MaleMar 5, 2012
  2. Junio C HamanoMar 5, 2012
  3. Jeff KingMar 6, 2012

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.