相对于主分支还是对当前分支是基础?

时间:2019-07-08 20:42:30

标签: git rebase

如果我有一个功能分支,我一直在努力并想清理它,例如将所有提交压缩为1个提交,我会

  1. 根据该功能分支git rebase <COMMIT>的第一次提交重新设置;或

  2. 反对大师? git rebase -i master

我不确定用例和两者的区别。

1 个答案:

答案 0 :(得分:1)

通常,您可以使用以下任何一种方式:

git rebase -i the-other-branch
# pick the first revision, squash the others. That will work

您也可以按照我的方式做

git merge -m "Getting updates from main branch" master # do not worry, we will get rid of this revision next
git reset --soft master # now all differences between your branch and master (in other words, all changes related to your feature branch) will be in index
git commit -m "My feature"

希望有帮助。

相关问题