简体   繁体   中英

What is the Git equivalent of tagging from a working copy in Subversion?

I've got a project which has a manifest file (which includes a version number), but not a build process. When I was using Subversion, I'd handle this by changing the version number in the manifest from "SVN" to "1.3" or what have you, tagging from the working copy, and reverting the manifest. The version number then exists in the tag, but remains "SVN" in trunk.

Is there an equivalent for this in Git? It seems it should be possible to create a branch, commit the version number on it, tag, and delete the branch (leaving a headless tag), but that seems rather convoluted.

git commit -m "Change manifest version to vX.Y"
git tag -a -m "MyProject vX.Y" vX.Y
git reset --hard HEAD~1

The git reset command lets you wind your branch pointer back to an existing commit.

You can tag an arbitrary commit or object. You don't need to have the commit checked out to do it. For example:

git checkout master # You're on HEAD
git tag v1.0 HEAD~2 # Apply tag to 2nd commit behind HEAD

See gitrevisions(7) for all the ways you can specify the commit object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM