git rebase并保持标签更新 [英] git rebase and keep tags update

查看:229
本文介绍了git rebase并保持标签更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的git日志

commit beba35
aaa

commit 2d34d4
bbb(tag: ATag)

commit be2f8a
cccc

如果我使用git rebase并更改be2f8a,那么我将获得一个新的git日志

If I use git rebase and change be2f8a, then I will get a new git log

commit as2sd2e
aaa

commit sdf2sdf
bbb

commit be2f8a
cccc

我们知道,sdf2sdf2d34d4是相同的提交,即使它们具有不同的提交ID.但是标记将保留在2d34d4上,并且不会更新为sdf2sdf.

We know, sdf2sdf and 2d34d4 are same commits even if they have different commit id. But the tag will stay on 2d34d4 and will not update to sdf2sdf.

当我使用git rebase时,有什么方法可以使标记保持新提交吗?

Is the any way to keep tag follow new commit when I use git rebase?

推荐答案

标签更多地标记了时间上固定的内容(例如,发行版).但是,如果要使用标签,则可以手动使用git tag -f tagName commitHash进行更新.

Tags are more to mark something fixed in time (a release for example). However, if you want to use tags, you can use git tag -f tagName commitHash manually to update it.

话虽这么说,也许您想使用分支而不是标签.分支在四处移动"方面更加灵活.假设您具有以下条件:

This being said, maybe you would want to use a branch instead of a tag. Branches are more flexible in term of being "moved around". Say you have the following:

commit beba35 (yourBranch)
aaa

commit 2d34d4 (yourBranchTag)
bbb

commit be2f8a
cccc

(masterBranch)

您可以在masterBranch之上重新设置yourBranchTag的基础,而不是在masterBranch之上重新构建yourBranch的基础.

Instead of rebasing yourBranch on top of masterBranch, you can rebase yourBranchTag on top of masterBranch and then rebase yourBranch on top of yourBranchTag.

您最终不得不按顺序维护它们,但是它们都将保留在同一祖先行中.

You end up having to maintain them in the order, but they would all stay in the same ancestors line.

拥有这个yourBranchTag分支并不意味着您将保留或合并它,也许只是在日志中保留一个书签".一旦完成yourBranch的操作并准备好在masterBranch中进行合并,就可以放弃yourBranchTag了.

Having this yourBranchTag branch does not mean that you will keep it or merge it, maybe it is just to keep a "bookmark" in your log. Once you are done with yourBranch and it's ready to be merged in masterBranch, you can then ditch yourBranchTag.

这篇关于git rebase并保持标签更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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