Checkout tag?
I've managed to figure out you switch branches with the checkout command, like this:
Quoted 1 line
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.
Quoted 7 lines · Abscissa
I've managed to figure out you switch branches with the checkout command, like this:
Quoted 1 line
git checkout
branch_nameDoes 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) ...
Signature · 3 lines
Magnus Bäck Opinions are my own and do not necessarily SW Configuration Manager represent the ones of my employer, etc. Sony Ericsson
I saw that, but it seems to imply that it's not a simple:
Quoted 1 line
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.
Quoted 5 lines · Abscissa
I saw that, but it seems to imply that it's not a simple:
Quoted 1 line
git checkout
tag_namebecause 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?
Signature · 3 lines
Magnus Bäck Opinions are my own and do not necessarily SW Configuration Manager represent the ones of my employer, etc. Sony Ericsson
Hi,
Quoted 8 lines · Magnus Bäck
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
Quoted 13 lines · Jonathan Nieder
Quoted 8 lines · Magnus Bäck
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:
Quoted 7 lines
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.
Quoted 15 lines
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...
Quoted 6 lines
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".
Quoted 1 line
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.
Signature · 3 lines
Magnus Bäck Opinions are my own and do not necessarily SW Configuration Manager represent the ones of my employer, etc. Sony Ericsson
I saw that, but it seems to imply that it's not a simple:
Quoted 1 line
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.
I saw that, but it seems to imply that it's not a simple:
Quoted 1 line
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.
I saw that, but it seems to imply that it's not a simple:
Quoted 1 line
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.
I saw that, but it seems to imply that it's not a simple:
Quoted 1 line
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.
I saw that, but it seems to imply that it's not a simple:
Quoted 1 line
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.
I saw that, but it seems to imply that it's not a simple:
Quoted 1 line
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.
I saw that, but it seems to imply that it's not a simple:
Quoted 1 line
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.
Quoted 6 lines · Magnus Bäck
Quoted 3 lines · Abscissa
I've managed to figure out you switch branches with the checkout command, like this:
Quoted 8 lines
Quoted 4 lines
$ git checkout branch_nameDoes 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 [email protected] to post, and it is custom here to send replies also to author(s)).
Signature · 1 line
Jakub Narebski
Quoted 7 lines · Abscissa
I've managed to figure out you switch branches with the checkout command, like this:
Quoted 1 line
git checkout
branch_nameDoes 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.
Signature · 1 line
Duy
I saw that, but it seems to imply that it's not a simple:
Quoted 1 line
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.
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.