[ot] checking out a git tag and only the tag

Ian Young ian at iay.org.uk
Sat Jan 18 07:14:58 EST 2014


On 17 Jan 2014, at 20:46, Tom Zeller <tzeller at dragonacea.biz> wrote:

> If I clone spring-framework, then 'git checkout tags/v3.2.6.RELEASE'
> or 'git checkout v3.2.6.RELEASE', then the spring-beans-groovy
> directory still exists, even though it does not exist in the tag,
> AFAICT, according to github.
> 
> Just wondering what I need to type to checkout the tag and only the tag.

So, I tried to reproduce this and that's not what happened for me. If I clone the repository and immediately do that checkout (those two forms are equivalent, I think, as long as there's no branch with the same name), I no longer have a spring-beans-groovy directory. If I then do "git checkout master" it comes back again. This is probably what you'd expect.

Had you made any changes at all within the spring-beans-groovy directory tree between the clone and checkout? Even looking at it in the Mac Finder might drop a .DS_Store file, for example, and if that's not in .gitignore then it would count.

If so, it's probably a side-effect of one of the properties of putting yourself into a detached HEAD state, which is that it retains local changes rather than just discarding them.

If you do the thing Kevin says (create an checkout a new branch initialised to the same commit as the tag) then local changes would be discarded and you'll get a clean copy of the requested tagged state. In other words, your local changes will be thrown in the bin unless you've stashed them, but spring-beans-groovy will vanish.

	git checkout -b temporaryBranch startingTag

Your choice.

	-- Ian



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5943 bytes
Desc: not available
Url : http://shibboleth.net/pipermail/dev/attachments/20140118/eac74508/attachment-0001.bin 


More information about the dev mailing list