I have a tag named tag_0.0.1 which is being pushed in the same to Git Repository. I run the build several times a day. Instead of creating new tags every time, I want to rewrite the same tag. New changes should be applied on the existing tag and it can be pushed to the repo. I know we can delete the tag on the repo and create the same in local and push it. Is there any way to apply new commits on the existing tags ?
This is what i tried:
git tag
tag_0.0.1
After code changes -- deleting
git tag -d tag_0.0.1
git push --delete origin tag_0.0.1
Recreating the same and push
git tag tag_0.0.1
git push --tags
I have a feeling about it doesn't make a sense. Is there any better ways ? I also want to know how to push the specific commit instead of pushing all of them.
Every build changes should be tagged. so that we can get the specific commit at anytime.
Your build process should rather incorporate the last tag and the current SHA1, using git describe.
You can see an example in "Automatic versioning in Xcode with git-describe" (or even git describe --dirty), using
VERSION=`git describe --dirty |sed -e "s/^[^0-9]*//"`
Other examples:
- "Embed git commit hash in a .Net dll"
- "Maven plugin which includes build-time git repository information into an POJO /
*.properties"
That way:
- the binary you are building includes the information allowing you to know what exact version of the code was used to make said build.
- you limit the tags to the actual versions that count (like a stable version used to make an official release)
来源:https://stackoverflow.com/questions/26861497/applying-the-existing-tag-on-a-new-commit-in-git