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

Re: Checkout tag?

From
Jakub Narebski <jnareb@gmail.com>
Date
Jan 22, 2012, 11:30 UTC
Message-ID
<m3ipk4dlfy.fsf@localhost.localdomain>
In-Reply-To
<20120122101116.GA31022@jpl.local>
Magnus Bäck <magnus.back@sonyericsson.com> writes:
Show 14 quoted lines
> On Sunday, January 22, 2012 at 11:05 CET,
>      Abscissa <bus_nabble_git@semitwist.com> wrote:
> 
> > I've managed to figure out you switch branches with the checkout
> > command, like this:
> > 
> >   $ git checkout branch_name
> > 
> > Does that work for tags as well? The docs don't seem clear on that.
> > If not, how do you get the working copy to be a specific tag?
> 
> Yes, "git checkout" works for branches, tags, commit SHA-1s, and
> anything else that can be resolved to a SHA-1 identifying what to
> check out. [...]

Note however that because you can generate new commits only on top of local branches (refs/heads/*), if you check out something other than local branch, e.g.:

  $ git checkout v1.7.8
  $ git checkout origin/next
  $ git checkout HEAD^

you would be after such checkout in unnamed anonymous branch which contents corresponds to what you checked out. This state is called 'detached HEAD', and shows e.g. in "git branch output as

  $ git branch
  * (no branch)
  master
  ...

On the other hand if you don't want to checkout tag to explore it, but set contents of working area to the state it was in given tag, you can use

  $ git checkout v1.7.8 -- .
HTH

P.S. Instead of Nabble you can use GMane interface, or just use email (you don't have ot be subscribed to git@vger.kernel.org to post, and it is custom here to send replies also to author(s)).

-- 
Jakub Narebski
Previous: AbscissaNext: Nguyen Thai Ngoc Duy
Message 14 of 17 in “Checkout tag?”
  1. AbscissaJan 22, 2012
  2. Magnus BäckJan 22, 2012
  3. AbscissaJan 22, 2012
  4. Magnus BäckJan 22, 2012
  5. Jonathan NiederJan 22, 2012
  6. Magnus BäckJan 22, 2012
  7. AbscissaJan 22, 2012
  8. AbscissaJan 22, 2012
  9. AbscissaJan 22, 2012
  10. AbscissaJan 22, 2012
  11. AbscissaJan 22, 2012
  12. AbscissaJan 22, 2012
  13. AbscissaJan 22, 2012
  14. Jakub NarebskiJan 22, 2012
  15. Nguyen Thai Ngoc DuyJan 22, 2012
  16. AbscissaJan 22, 2012
  17. AbscissaJan 22, 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.