[英]Reverting a branch changes tag name of git describe
I just learned how to revert a branch. 我刚刚学习了如何还原分支。 That works fine.
很好 The thing is, I tagged the master's commits and I plan to use the
git describe
command to create deployments based on the latest tag. 事情是,我标记了主数据库的提交,我计划使用
git describe
命令基于最新标记创建部署。 Reverting a commit creates a new commit, so the git describe
command outputs the tag with the commit ammend, like so: 还原提交会创建一个新的提交,因此
git describe
命令输出带有提交修订的标签,如下所示:
Before: 之前:
git describe
1-2-0
After revert 'back' to this commit: 将“ back”恢复为该提交后:
git describe
1-2-0-1ga99ae04
Is there a way to overcome this? 有办法克服吗? Or should I get the latest tag differently?
还是应该以其他方式获得最新标签?
Just to be clear. 只是要清楚。 You dont really revert "back".
您实际上并不还原“返回”。 Say you have the following history.
假设您有以下历史记录。
A<--B<--C<--D
|
(tag:1-2-0)
Now say you revert C
. 现在说您还原
C
This is what happens. 这就是发生的情况。
A<--B<--C<--D<--E
|
(tag:1-2-0)
As you can see you have moved forward in history. 如您所见,您已经在历史上前进了。 If this tag has already been released, then you probably want to consider this a "hotfix", and tag again as
1-2-0-1
, or something along those lines. 如果该标签已经发布,则您可能希望将此标签视为“修补程序”,并再次将标签标记为
1-2-0-1
或类似的内容。 Not sure what your version number scheme is, so obviously just work hotfixes into your process. 不知道您的版本号方案是什么,因此很明显,您只需在流程中使用修补程序即可。
Considering this change a hotfix would result in this. 考虑此更改,修复程序将导致此。
(tag:1-2-0-1)
|
A<--B<--C<--D<--E
|
(tag:1-2-0)
However if you have not released or even pushed this tag up to the remote, and just want to move the tag to point to E
, then you can do this two ways. 但是,如果您尚未释放该标签,甚至没有将其推到遥控器上,只想移动标签指向
E
,则可以使用两种方法。 The easy to remember way is to delete the tag and recreate it. 容易记住的方法是删除标签并重新创建它。
git tag -d 1-2-0
git tag 1-2-0 E
The shorter, faster, but infinitely less friendly way to change the tag without deleting it would be to use update-ref
. 更改标签而不删除标签的一种更短,更快,但无限友好的方法是使用
update-ref
。
git update-ref refs/tags/1-2-0 E
In the odd case that you have pushed the tag up and want to remove it from the remote, use the following syntax. 在奇怪的情况下,您已将标签向上推并想要将其从遥控器中删除,请使用以下语法。
git push <remote> :1-2-0
Assuming origin is your remote. 假设来源是您的遥控器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.