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

Re: Proper way to checkout a tag?

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Dec 1, 2010, 19:51 UTC
Message-ID
<20101201195125.GC27347@burratino>
In-Reply-To
<AANLkTi=b12n0J+Qg4S7i9dnbMHoWvPS3OXP0CDZevT_4@mail.gmail.com>
Hi,
Dun Peal wrote:
Show 11 quoted lines
> The problem is that since there's no head pointing to each release, if
> our users just:
> 
> $ git checkout release-1
> 
> When they want to build that release, they get into a detached HEAD
> state. I've always construed detached HEAD as a non-standard state,
> and it doesn't seem proper to reach it regularly in the course of a
> standard operation like checking out past releases.
> 
> It's particularly confusing for our users who are new to Git.
Any ideas for making the detached state more friendly?

The idea is this: when you check out a tag or a remote-tracking branch, it is not to make changes to it. Tags are unchanging, remote-tracking branches track remote state that the user does not directly control. So what does it mean to check out such a thing?

There are two possibilities:

If you are checking out that commit to examine it, test it, maybe write a few one-off patches, then any work built from there does not need to be remembered (except in the HEAD reflog, to avoid expensive accidents). You can make an experiment permanent with

	git checkout -b newbranch

If you are starting a new line of development, it needs to get a name. Long ago this was the only use case supported. Even today it is often a good way to go:

	git checkout -b newbranch release-1

Hope that helps. Jonathan

Previous: Dun PealNext: Dun Peal
Message 2 of 4 in “Proper way to checkout a tag?”
  1. Dun PealDec 1, 2010
  2. Jonathan NiederDec 1, 2010
  3. Dun PealDec 1, 2010
  4. Michael J GruberDec 2, 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.