如何编辑是多个分支的共同祖先的提交

如何编辑是多个分支的共同祖先的提交

本文介绍了如何编辑是多个分支的共同祖先的提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

branch A
|
| branch B
| |
|/
|
commit X
|
|
...

如何编辑提交X使其成为X',以使A和B在其历史记录中都具有X'?(所有提交和分支都是本地的.)

How do I edit commit X to become X' such that both A and B have X' in their history? (All commits and branches are local.)

推荐答案

您必须重写分支历史记录(及其所有含义):

You have to rewrite branches history (with all its implications):

git checkout x
# do changes
git add .
git commit --amend
# now we have X'... let's create a temp branch here
git branch temp
git rebase --onto temp x A # rebase branch A onto temp
git rebase --onto temp x B # rebase branch B onto temp

现在,您可以删除temp

Now, you could delete temp

git branch -d temp

这篇关于如何编辑是多个分支的共同祖先的提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 20:11