git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Checkout tag?
@ 2012-01-22 10:05 Abscissa
  2012-01-22 10:11 ` Magnus Bäck
  2012-01-22 10:18 ` Nguyen Thai Ngoc Duy
  0 siblings, 2 replies; 17+ messages in thread
From: Abscissa @ 2012-01-22 10:05 UTC (permalink / raw
  To: git

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?


--
View this message in context: http://git.661346.n2.nabble.com/Checkout-tag-tp7213023p7213023.html
Sent from the git mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Checkout tag?
  2012-01-22 10:05 Checkout tag? Abscissa
@ 2012-01-22 10:11 ` Magnus Bäck
  2012-01-22 10:25   ` Abscissa
                     ` (8 more replies)
  2012-01-22 10:18 ` Nguyen Thai Ngoc Duy
  1 sibling, 9 replies; 17+ messages in thread
From: Magnus Bäck @ 2012-01-22 10:11 UTC (permalink / raw
  To: Abscissa; +Cc: git

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. The git-checkout(1) man page says the following:

       git checkout [--patch] [<tree-ish>] [--] <pathspec>...
           ... The <tree-ish> argument can be used to specify a
           specific tree-ish (i.e. commit, tag or tree) ...

-- 
Magnus Bäck                   Opinions are my own and do not necessarily
SW Configuration Manager      represent the ones of my employer, etc.
Sony Ericsson

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Checkout tag?
  2012-01-22 10:05 Checkout tag? Abscissa
  2012-01-22 10:11 ` Magnus Bäck
@ 2012-01-22 10:18 ` Nguyen Thai Ngoc Duy
  2012-01-22 10:29   ` Abscissa
  1 sibling, 1 reply; 17+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2012-01-22 10:18 UTC (permalink / raw
  To: Abscissa; +Cc: git

On Sun, Jan 22, 2012 at 5:05 PM, 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?

Magnus already answered your checkout question. I just want to add
that you can view a tag's content even without checking out. For
example,"git archive" can create a zip/tarball of any tree-ish. "git
ls-tree" lets you view directory structure of a tree-ish, "git show
<tree-ish>:path" lets you view content of a specific file.
-- 
Duy

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Checkout tag?
  2012-01-22 10:11 ` Magnus Bäck
@ 2012-01-22 10:25   ` Abscissa
  2012-01-22 11:31     ` Magnus Bäck
  2012-01-22 10:26   ` Abscissa
                     ` (7 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Abscissa @ 2012-01-22 10:25 UTC (permalink / raw
  To: git

I saw that, but it seems to imply that it's not a simple:

>git checkout tag_name

because of the required <pathspec>, whatever that is.

--
View this message in context: http://git.661346.n2.nabble.com/Checkout-tag-tp7213023p7213061.html
Sent from the git mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Checkout tag?
  2012-01-22 10:11 ` Magnus Bäck
  2012-01-22 10:25   ` Abscissa
@ 2012-01-22 10:26   ` Abscissa
  2012-01-22 10:26   ` Abscissa
                     ` (6 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Abscissa @ 2012-01-22 10:26 UTC (permalink / raw
  To: git

I saw that, but it seems to imply that it's not a simple:

>git checkout tag_name

because of the required <pathspec>, whatever that is.

--
View this message in context: http://git.661346.n2.nabble.com/Checkout-tag-tp7213023p7213063.html
Sent from the git mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Checkout tag?
  2012-01-22 10:11 ` Magnus Bäck
  2012-01-22 10:25   ` Abscissa
  2012-01-22 10:26   ` Abscissa
@ 2012-01-22 10:26   ` Abscissa
  2012-01-22 10:27   ` Abscissa
                     ` (5 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Abscissa @ 2012-01-22 10:26 UTC (permalink / raw
  To: git

I saw that, but it seems to imply that it's not a simple:

>git checkout tag_name

because of the required <pathspec>, whatever that is.

--
View this message in context: http://git.661346.n2.nabble.com/Checkout-tag-tp7213023p7213066.html
Sent from the git mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Checkout tag?
  2012-01-22 10:11 ` Magnus Bäck
                     ` (2 preceding siblings ...)
  2012-01-22 10:26   ` Abscissa
@ 2012-01-22 10:27   ` Abscissa
  2012-01-22 10:27   ` Abscissa
                     ` (4 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Abscissa @ 2012-01-22 10:27 UTC (permalink / raw
  To: git

I saw that, but it seems to imply that it's not a simple:

>git checkout tag_name

because of the required <pathspec>, whatever that is.

--
View this message in context: http://git.661346.n2.nabble.com/Checkout-tag-tp7213023p7213069.html
Sent from the git mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Checkout tag?
  2012-01-22 10:11 ` Magnus Bäck
                     ` (3 preceding siblings ...)
  2012-01-22 10:27   ` Abscissa
@ 2012-01-22 10:27   ` Abscissa
  2012-01-22 10:28   ` Abscissa
                     ` (3 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Abscissa @ 2012-01-22 10:27 UTC (permalink / raw
  To: git

I saw that, but it seems to imply that it's not a simple:

>git checkout tag_name

because of the required <pathspec>, whatever that is.

--
View this message in context: http://git.661346.n2.nabble.com/Checkout-tag-tp7213023p7213072.html
Sent from the git mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Checkout tag?
  2012-01-22 10:11 ` Magnus Bäck
                     ` (4 preceding siblings ...)
  2012-01-22 10:27   ` Abscissa
@ 2012-01-22 10:28   ` Abscissa
  2012-01-22 10:28   ` Abscissa
                     ` (2 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Abscissa @ 2012-01-22 10:28 UTC (permalink / raw
  To: git

I saw that, but it seems to imply that it's not a simple:

>git checkout tag_name

because of the required <pathspec>, whatever that is.

--
View this message in context: http://git.661346.n2.nabble.com/Checkout-tag-tp7213023p7213074.html
Sent from the git mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Checkout tag?
  2012-01-22 10:11 ` Magnus Bäck
                     ` (5 preceding siblings ...)
  2012-01-22 10:28   ` Abscissa
@ 2012-01-22 10:28   ` Abscissa
  2012-01-22 10:29   ` Abscissa
  2012-01-22 11:30   ` Jakub Narebski
  8 siblings, 0 replies; 17+ messages in thread
From: Abscissa @ 2012-01-22 10:28 UTC (permalink / raw
  To: git

I saw that, but it seems to imply that it's not a simple:

>git checkout tag_name

because of the required <pathspec>, whatever that is.

--
View this message in context: http://git.661346.n2.nabble.com/Checkout-tag-tp7213023p7213076.html
Sent from the git mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Checkout tag?
  2012-01-22 10:11 ` Magnus Bäck
                     ` (6 preceding siblings ...)
  2012-01-22 10:28   ` Abscissa
@ 2012-01-22 10:29   ` Abscissa
  2012-01-22 11:30   ` Jakub Narebski
  8 siblings, 0 replies; 17+ messages in thread
From: Abscissa @ 2012-01-22 10:29 UTC (permalink / raw
  To: git

I saw that, but it seems to imply that it's not a simple:

>git checkout tag_name

because of the required <pathspec>, whatever that is.

--
View this message in context: http://git.661346.n2.nabble.com/Checkout-tag-tp7213023p7213078.html
Sent from the git mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Checkout tag?
  2012-01-22 10:18 ` Nguyen Thai Ngoc Duy
@ 2012-01-22 10:29   ` Abscissa
  2012-01-22 10:34     ` Abscissa
  0 siblings, 1 reply; 17+ messages in thread
From: Abscissa @ 2012-01-22 10:29 UTC (permalink / raw
  To: git

I saw that, but it seems to imply that it's not a simple:

>git checkout tag_name

because of the required <pathspec>, whatever that is.

--
View this message in context: http://git.661346.n2.nabble.com/Checkout-tag-tp7213023p7213081.html
Sent from the git mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Checkout tag?
  2012-01-22 10:29   ` Abscissa
@ 2012-01-22 10:34     ` Abscissa
  0 siblings, 0 replies; 17+ messages in thread
From: Abscissa @ 2012-01-22 10:34 UTC (permalink / raw
  To: git

Sorry for the duplicates. Nabble kept crashing every time I tried to post,
but I guess it was crashing after it posted to the mailing list.

--
View this message in context: http://git.661346.n2.nabble.com/Checkout-tag-tp7213023p7213090.html
Sent from the git mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Checkout tag?
  2012-01-22 10:11 ` Magnus Bäck
                     ` (7 preceding siblings ...)
  2012-01-22 10:29   ` Abscissa
@ 2012-01-22 11:30   ` Jakub Narebski
  8 siblings, 0 replies; 17+ messages in thread
From: Jakub Narebski @ 2012-01-22 11:30 UTC (permalink / raw
  To: Magnus Bäck; +Cc: Abscissa, git

Magnus Bäck <magnus.back@sonyericsson.com> writes:
> 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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Checkout tag?
  2012-01-22 10:25   ` Abscissa
@ 2012-01-22 11:31     ` Magnus Bäck
  2012-01-22 17:08       ` Jonathan Nieder
  0 siblings, 1 reply; 17+ messages in thread
From: Magnus Bäck @ 2012-01-22 11:31 UTC (permalink / raw
  To: Abscissa; +Cc: git

On Sunday, January 22, 2012 at 11:25 CET,
     Abscissa <bus_nabble_git@semitwist.com> wrote:

> I saw that, but it seems to imply that it's not a simple:
> 
> >git checkout tag_name
> 
> because of the required <pathspec>, whatever that is.

It isn't required. The part of the manual that I quoted (from Git
1.7.2.5) indicated that the pathspec is mandatory, but looking at
the command synopsis at the top of the man page it's actually listed
as optional.

Looking at an up to date Git 1.7.9-rc2 man page, it still seems
slightly inconsistent with itself. The synopsis at the top says

      git checkout [-p|--patch] [<tree-ish>] [--] [<paths>...]

while the text in the DESCRIPTION section says

      git checkout [-p|--patch] [<tree-ish>] [--] <pathspec>...

The DETACHED HEAD section of the man page contains an example of
checking out a tag, by the way.

If you're doubtful, why don't you just create a tag and try things
out for yourself?

-- 
Magnus Bäck                   Opinions are my own and do not necessarily
SW Configuration Manager      represent the ones of my employer, etc.
Sony Ericsson

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Checkout tag?
  2012-01-22 11:31     ` Magnus Bäck
@ 2012-01-22 17:08       ` Jonathan Nieder
  2012-01-22 17:33         ` Magnus Bäck
  0 siblings, 1 reply; 17+ messages in thread
From: Jonathan Nieder @ 2012-01-22 17:08 UTC (permalink / raw
  To: Magnus Bäck; +Cc: Abscissa, git, Jakub Narebski, Nguyen Thai Ngoc Duy

Hi,

Magnus Bäck wrote:

> Looking at an up to date Git 1.7.9-rc2 man page, it still seems
> slightly inconsistent with itself. The synopsis at the top says
>
>       git checkout [-p|--patch] [<tree-ish>] [--] [<paths>...]
>
> while the text in the DESCRIPTION section says
>
>       git checkout [-p|--patch] [<tree-ish>] [--] <pathspec>...

Hmm, my copy says:

	SYNOPSIS

	git checkout [-q] [-f] [-m] [<branch>]
	git checkout [-q] [-f] [-m] [--detach] [<commit>]
	git checkout [-q] [-f] [-m] [[-b|-B|--orphan] <new_branch>] [<start_point>]
	git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>...
	git checkout [-p|--patch] [<tree-ish>] [--] [<paths>...]

	DESCRIPTION

	... overview ...

	git checkout [<branch>], git checkout -b|-B <new_branch> [<start point>],
	git checkout [--detach] [<commit>]

		This form switches branches by updating the index, working
		tree, and HEAD...

	git checkout [-p|--patch] [<tree-ish>] [--] <pathspec>...

		When <paths> or --patch are given, git checkout does not
		switch branches. It updates the named paths...

So in the synopsis it lists five forms, and in the description section
it lists two forms, the first of which has three variants.

It's not immediately obvious to me which inconsistency you are
pointing to as a source of confusion.  Could you elaborate, preferably
with suggested wording for a fix?  If you can do so in the form of a
patch, all the better. ;-)

Thanks,
Jonathan

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Checkout tag?
  2012-01-22 17:08       ` Jonathan Nieder
@ 2012-01-22 17:33         ` Magnus Bäck
  0 siblings, 0 replies; 17+ messages in thread
From: Magnus Bäck @ 2012-01-22 17:33 UTC (permalink / raw
  To: Jonathan Nieder
  Cc: Magnus Bäck, Abscissa, git, Jakub Narebski,
	Nguyen Thai Ngoc Duy

On Sunday, January 22, 2012 at 18:08 CET,
     Jonathan Nieder <jrnieder@gmail.com> wrote:

> Magnus Bäck wrote:
> 
> > Looking at an up to date Git 1.7.9-rc2 man page, it still seems
> > slightly inconsistent with itself. The synopsis at the top says
> >
> >       git checkout [-p|--patch] [<tree-ish>] [--] [<paths>...]
> >
> > while the text in the DESCRIPTION section says
> >
> >       git checkout [-p|--patch] [<tree-ish>] [--] <pathspec>...
> 
> Hmm, my copy says:
> 
> 	SYNOPSIS
> 
> 	git checkout [-q] [-f] [-m] [<branch>]
> 	git checkout [-q] [-f] [-m] [--detach] [<commit>]
> 	git checkout [-q] [-f] [-m] [[-b|-B|--orphan] <new_branch>] [<start_point>]
> 	git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>...
> 	git checkout [-p|--patch] [<tree-ish>] [--] [<paths>...]

Perhaps I wasn't clear -- I didn't mean that the synopsis *only* listed
the form in my original quote above.

> 	DESCRIPTION
> 
> 	... overview ...
> 
> 	git checkout [<branch>], git checkout -b|-B <new_branch> [<start point>],
> 	git checkout [--detach] [<commit>]
> 
> 		This form switches branches by updating the index, working
> 		tree, and HEAD...
> 
> 	git checkout [-p|--patch] [<tree-ish>] [--] <pathspec>...
> 
> 		When <paths> or --patch are given, git checkout does not
> 		switch branches. It updates the named paths...
> 
> So in the synopsis it lists five forms, and in the description section
> it lists two forms, the first of which has three variants.
> 
> It's not immediately obvious to me which inconsistency you are
> pointing to as a source of confusion.  Could you elaborate,
> preferably with suggested wording for a fix?

I simply meant that

   git checkout [-p|--patch] [<tree-ish>] [--] [<paths>...]
   git checkout [-p|--patch] [<tree-ish>] [--] <pathspec>...

aren't identical even though I assume they describe the exact same
scenario. The first command synopsis makes it clear that paths are
optional while the second indicates that at least one path must be
specified (unless "..." means "zero, one, or more occurences").
Also, "paths" != "pathspec".

> If you can do so in the form of a patch, all the better. ;-)

Sure, but it won't be during the coming week. Not that the patch is
terribly difficult to prepare but because I need legal approval to
submit it, and it's not clear I'll have time to deal with all that
during my last week at work.

-- 
Magnus Bäck                   Opinions are my own and do not necessarily
SW Configuration Manager      represent the ones of my employer, etc.
Sony Ericsson

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2012-01-22 17:35 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-22 10:05 Checkout tag? Abscissa
2012-01-22 10:11 ` Magnus Bäck
2012-01-22 10:25   ` Abscissa
2012-01-22 11:31     ` Magnus Bäck
2012-01-22 17:08       ` Jonathan Nieder
2012-01-22 17:33         ` Magnus Bäck
2012-01-22 10:26   ` Abscissa
2012-01-22 10:26   ` Abscissa
2012-01-22 10:27   ` Abscissa
2012-01-22 10:27   ` Abscissa
2012-01-22 10:28   ` Abscissa
2012-01-22 10:28   ` Abscissa
2012-01-22 10:29   ` Abscissa
2012-01-22 11:30   ` Jakub Narebski
2012-01-22 10:18 ` Nguyen Thai Ngoc Duy
2012-01-22 10:29   ` Abscissa
2012-01-22 10:34     ` Abscissa

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).