tags:

views:

117

answers:

1

I did:

git clone git://github.com/xyz/xyz.git  
git tag -l  
 release-1.0.0  
 release-1.0.1  
 release-1.0.2  
git checkout release-1.0.2  
git checkout -b xyzfilter

and now I think that I have a new branch, called xyzfilter, based on the tag 'release-1.0.2'.

Did I do this correctly ?

+3  A: 

Yes, that looks correct, assuming that there weren't any major errors in the execution of any of the commands.

If release-1.0.2 is a tag rather than a branch (which it must be for this to work after a straight clone), then this creates a 'detached HEAD' and checks out the version at the tag.

git checkout release-1.0.2

Then this command creates a new branch based on the currently checked out version (i.e. the tag that was just checked out) and switches to the new branch.

git checkout -b xyzfilter
Charles Bailey
Is a detached head good or bad ?
What are the future consequences of a detached head ? (no pun intended...)
Loss of blood through the neck can be bad... but seriously nothing. Once you do the second checkout, you've re-attached your head in any case. When your head is detached, it just means that you're not on any branch so if you make any commits and then switch away they aren't recorded on any branch. You might have to use the reflog to find tham again.
Charles Bailey
I'm happy that surgery is not involved, I was really beginning to doubt my switch to git.
the detached HEAD stage could be skipped by combining the last two commands: "git checkout -b xyzfilter release-1.0.2" means "switch to a new branch called xyzfilter, initialised to be at revision 'release-1.0.2'"
araqnid