将现有标签应用于Git中的新提交 [英] Applying the existing tag on a new commit in Git

查看:94
本文介绍了将现有标签应用于Git中的新提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为tag_0.0.1的标签,该标签也被推送到Git存储库中.我一天运行几次构建.我不想每次都创建新标签,而是要重写相同的标签.新的更改应应用于现有标签,并且可以将其推送到存储库中.我知道我们可以删除仓库中的标签,并在本地创建标签并推送它.有什么方法可以在现有标签上应用新的提交?

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 ?

这是我尝试过的:

git标签

代码更改后-删除

git标签-d标签_0.0.1

git tag -d tag_0.0.1

重新创建并按下

git标签tag_0.0.1

git tag tag_0.0.1

git push --tags

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.

您的构建过程应该使用 git describe .

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]*//"`

其他示例:

  • "Embed git commit hash in a .Net dll"
  • "Maven plugin which includes build-time git repository information into an POJO / *.properties"

那样:

  • 您正在构建的二进制文件中包含的信息使您可以知道用于进行所述构建的代码的确切版本.
  • 您将标签限制为可以计数的实际版本(例如用于正式发布的稳定版本)

这篇关于将现有标签应用于Git中的新提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆