git 如何处理来自现已删除的分支的先前非快进合并?

发布于 2024-11-17 18:00:52 字数 254 浏览 3 评论 0原文

假设我有我的 master 分支,并且我创建了 feature-x 分支来处理新功能。我对 feature-x 进行了多次提交,从 master 重新调整 feature-x 的基础,然后从 feature-x 分支到 master 分支进行非快进合并。

现在,如果我删除 feature-x 分支,我的提交历史记录会发生什么?

我正在进行非 ff 合并,因为在阅读一篇文章(我同意)后,通过进行非 ff 合并可以更轻松地跟踪功能特定的更改和功能的完整生命周期。

So say I have my master branch, and I create feature-x branch to work on a new feature. I do several commits into feature-x, rebase feature-x from master and then do a non fast-forward merge from feature-x branch to the master branch.

Now what happens to my commit history if I then delete the feature-x branch?

I am doing a non-ff merge because after reading an article (that I agree with) it's easier to keep track of feature specific changes and the full lifecycle of features by doing non-ff merges.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小嗷兮 2024-11-24 18:00:52

如果我理解正确的话,合并后的历史记录看起来像这样:

A-----------E
 \         /
  B---C---D

这里,D 是 rebase 后 feature-x 分支的头部,E 是合并后 master 分支的头部。删除 feature-x 分支后 master 会发生什么?没有什么。分支只是指向一个特定修订的指针(加上一些附加数据,例如引用日志),当您删除它时,您丢失的只是指针,主版本将与删除之前完全相同。

话虽这么说,我不确定你为什么要进行变基和合并。如果你想保持历史清晰,只需使用merge,不需要rebase。

If I understand you correctly, your history after the merge looks something like this:

A-----------E
 \         /
  B---C---D

Here, D is the head of feature-x branch after the rebase and E is the head of the master branch after the merge. What happens to master when you delete the feature-x branch? Nothing. Branch is just a pointer to one specific revision (plus some additional data like the reflog) and when you delete it, all you lose is just the pointer, the master will stay exactly the same as it was before you deleted it.

That being said, I'm not sure why are you doing rebase and merge. If you want to keep the history clear, just use merge, you don't need to rebase.

深海夜未眠 2024-11-24 18:00:52

历史真的没有发生任何事情。您仍然具有相同的提交序列(或真正有向无环图),并且分支名称仍将包含在合并提交消息中。

您只是删除特定提交的特定标签。

Nothing happens to the history, really. You still have the same sequence (or really directed acyclic graph) of commits, and the branch name will still be included in the merge commit message.

You're just deleting a particular label for a particular commit.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文