更新:使用提交散列而不是基本分支。
是的,我会重订。我知道有一种更快捷的方法可以通过“rebase to”来实现这一点,但我总是感到困惑,因为如何才能把它做好。我会做的是创建新的分支与一切,然后删除你不想要的。
基地犯下
你需要的第一件事是为提交答:您会在接下来的步骤中使用此为git rebase
提交哈希值。
## Copy the 6-char hex value next to commit "A"
git log --oneline
特征1
git checkout -b feature1 master
# insert the commit hash for commit A
git rebase -i $A
# in the VI editor, delete the line representing commit B, and save
特征2
git checkout -b feature2 devel
# insert the commit hash for commit A
git rebase -i $A
# in the VI editor, delete the line representing commit C, and save
上git rebase
的-i
标志指示执行“的Intera cive rebase“。这就是为什么你会看到一位编辑。阅读内置说明,根据需要告知自己将来可以做什么。除了重新绑定本地提交以抵御上游更新,我几乎每天都会使用它来重命名提交并将提交合并到一个提交中,然后再将更改推回上游。这是一个非常强大的工具,可以理解并且不那么复杂。