Re: [git-users] Git checkout behavior when you have a tag and a branch with the same name
Wonderful, thank you very much Konstantin! :) Nando Il giorno mercoledì 5 aprile 2017 12:01:07 UTC+2, Konstantin Khomoutov ha scritto: > > On Wed, 5 Apr 2017 00:22:28 -0700 (PDT) > Ferdinando Santacroce > wrote: > > [...] > > Supposing there are a branch and a tag called , when I do: > > $ git checkout something > > Git checks out the tag , and not the branch. > > Furthermore, it leaves me in a detached HEAD state. > > > > So, I'm looking for documentation about this behavior, and I'm > > wondering if there's a way to prefer branches over tags or other > > options I can set. > [...] > > This is covered by the gitrevisions manual page > (run `git help revisions`); in particular: > > , e.g. master, heads/master, refs/heads/master > A symbolic ref name. E.g. master typically means the commit > object referenced by refs/heads/master. If you happen to have both > heads/master and tags/master, you can explicitly say heads/master to > tell Git which one you mean. When ambiguous, a is > disambiguated by taking the first match in the following rules: > > 1. If $GIT_DIR/ exists, that is what you mean > (this is usually useful only for HEAD, FETCH_HEAD, ORIG_HEAD, > MERGE_HEAD and CHERRY_PICK_HEAD); > > 2. otherwise, refs/ if it exists; > > 3. otherwise, refs/tags/ if it exists; > > 4. otherwise, refs/heads/ if it exists; > > 5. otherwise, refs/remotes/ if it exists; > > 6. otherwise, refs/remotes//HEAD if it exists. > > So, if there exists a tag and a branch of the same name, using of an > unadorned ref name would select the tag (rule 3), and if you want to be > precise, use the full name: > > git checkout refs/heads/something > > to pick the branch named "something" over the same-named tag. > -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [git-users] Git checkout behavior when you have a tag and a branch with the same name
On Wed, 5 Apr 2017 00:22:28 -0700 (PDT) Ferdinando Santacroce wrote: [...] > Supposing there are a branch and a tag called , when I do: > $ git checkout something > Git checks out the tag , and not the branch. > Furthermore, it leaves me in a detached HEAD state. > > So, I'm looking for documentation about this behavior, and I'm > wondering if there's a way to prefer branches over tags or other > options I can set. [...] This is covered by the gitrevisions manual page (run `git help revisions`); in particular: , e.g. master, heads/master, refs/heads/master A symbolic ref name. E.g. master typically means the commit object referenced by refs/heads/master. If you happen to have both heads/master and tags/master, you can explicitly say heads/master to tell Git which one you mean. When ambiguous, a is disambiguated by taking the first match in the following rules: 1. If $GIT_DIR/ exists, that is what you mean (this is usually useful only for HEAD, FETCH_HEAD, ORIG_HEAD, MERGE_HEAD and CHERRY_PICK_HEAD); 2. otherwise, refs/ if it exists; 3. otherwise, refs/tags/ if it exists; 4. otherwise, refs/heads/ if it exists; 5. otherwise, refs/remotes/ if it exists; 6. otherwise, refs/remotes//HEAD if it exists. So, if there exists a tag and a branch of the same name, using of an unadorned ref name would select the tag (rule 3), and if you want to be precise, use the full name: git checkout refs/heads/something to pick the branch named "something" over the same-named tag. -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[git-users] Git checkout behavior when you have a tag and a branch with the same name
Hi. I'm helping some guys to migrate from SVN to Git. They are facing some obstacles, and I'm learning new things about SVN and Git while helping them solve those problems :) It happened that in a repo there was a tag and a branch with the same name. Leaving SVN aside for a moment, I quickly build up a Git repo on my personal Gitlab server to replicate this scenario, then I cloned it. Supposing there are a branch and a tag called , when I do: $ git checkout something Git checks out the tag , and not the branch. Furthermore, it leaves me in a detached HEAD state. So, I'm looking for documentation about this behavior, and I'm wondering if there's a way to prefer branches over tags or other options I can set. It's only for my knowledge, not a real problem in fact :) Thanks, Nando -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.