Applying the existing tag on a new commit in Git

匿名 (未验证) 提交于 2019-12-03 09:06:55

问题:

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.

回答1:

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:

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)


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!