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

[SOLVED] `git fetch tag NAME' into mirror repo does not update HEAD, what to do?

From
BFBrian Foster <brian.foster@innova-card.com>
Date
Aug 12, 2010, 12:16 UTC
Message-ID
<201008121416.35887.brian.foster@innova-card.com>
In-Reply-To
<4C63D579.507@dbservice.com>
On Thursday 12 August 2010 13:05:29 Tomas Carnecky wrote:
Show 10 quoted lines
> On 8/12/10 12:38 PM, Brian Foster wrote:
> > On Thursday 12 August 2010 10:33:13 Tomas Carnecky wrote:
> >[ ... ]
> >> Fetch only fetches commits. It doesn't update any local refs (other than
> >> FETCH_HEAD). If you want to switch HEAD to that new tag, use checkout.
> 
> Oh boy, that explanation is really bad -.- What I meant is that if
> you don't supply the <dst> part of the refspec it will only update
> FETCH_HEAD. So 'git fetch origin master' will not update anything
> but FETCH_HEAD.
 I concur.  However, the “refspec” in this case is the obscure
 ‘tag TAGNAME’ (where the ‘tag’ is a keyword); see get-fetch(1)
 at the end of §OPTIONS where it describes “short-cut notations”.
 That does not seem to accept a :<dst>, nor would I be too sure
 what it meant if it did.
Show 7 quoted lines
> >  No, a fetch in a mirror, when fetching all the way
> >  to the HEAD (e.g., a simple `git fetch origin'),
> >  does update the branch.  [ ... ]
> 
> There are different ways to invoke git fetch. Either way, fetch will
> never modify HEAD. However, it can modify the branch that HEAD is
> pointing to (in case HEAD is a symref). 
 Point taken, I was being sloppy.  We want the head of the
 relevant branch (master) to be updated in our bare (mirror)
 repository.
>                                         But you are not fetching a
> branch, you are fetching a tag. So you need to use checkout after you
> fetch it. Either 'git checkout FETCH_HEAD' or 'git checkout v2'.
 NO.  ‘get checkout ...’ does not work in a bare repository.
 (You can modify my trivial posted script to prove this.)
 However, your comment got me to thinking.  This _does_ work:
    git reset --soft FETCH_HEAD
 (And, I presume without testing, so would ‘... v2’ ?)
 Given that git-reset(1)'s purpose is to change the branch's
 head (or to change HEAD as I've been incorrectly describing
 it), that does make sense.
cheers!
	-blf-
Previous: Tomas CarneckyNext: Tomas Carnecky
Message 5 of 11 in “[Q] `git fetch tag NAME' into mirror repo does not update HEAD, what to do?”
  1. Brian FosterAug 12, 2010
  2. Tomas CarneckyAug 12, 2010
  3. Brian FosterAug 12, 2010
  4. Tomas CarneckyAug 12, 2010
  5. [SOLVED] `git fetch tag NAME' into mirror repo does not update HEAD, what to do?Brian Foster, Aug 12, 2010
  6. Tomas CarneckyAug 12, 2010
  7. Brian FosterAug 12, 2010
  8. Tomas CarneckyAug 12, 2010
  9. Brian FosterAug 13, 2010
  10. Brandon CaseyAug 12, 2010
  11. Brian FosterAug 13, 2010

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.