git - 尝试压缩提交后,交互式变基不断添加步骤
问题描述
当我的分支基于自身以通过将它们压缩在一起来清理提交时,我的 rebase 卡在一个循环中,不知道如何打破这个。这适用于我正在处理的每个分支,而不仅仅是一个特定的分支。
例如说我有一个分支my-branch三个提交
commit 1
commit 2
commit 3
在我的终端中,我写git rebase -i origin my-branch
这将我带到了交互式 git(以我的 Sublime 文本为例)
在这里,我看到了我所有的提交并将最后一个更改为 squash,这样我就只有提交 1 和 2:
p commit 1
p commit 2
s commit 3
从这里,我看到另一个交互式窗口,在其中我删除了提交 3 的提交消息,只留下了提交 2。
这一切似乎都在工作,但现在陷入了一个循环。
例如,在我的终端上,它位于变基 STEP 3/3 上,然后我rebase --continue
继续执行 STEP 4/4(没有更改)rebase --continue
,再次执行 STEP 5/5,依此类推,而实际上并未离开变基。
我被迫使用rebase --abort
并且我的提交不是壁球。
解决方案
如果你想压缩到最后 rebase,你可以跳过使用 rebase -i 这个技巧:
git checkout my-feature
git merge master # merge with the branch you want to rebase onto
# don't worry, that will go away with the following steps
git reset --soft master # move branch pointer to master, all changes between your branch and master (theoretically speaking, all changes related to your feature _only_ will be in index
git commit -m "My feature"
而已。
推荐阅读
- angular - 如何在 Ionic 中使用相同的模型进行添加和编辑
- python - 使用opencv获取蒙版后如何模糊图像?
- c++ - *的位置有什么区别:*变量与变量*
- javascript - Javascript在画布上模拟鼠标移动事件
- javascript - 如何使用 angular 6 的 save-svg-as-png
- css - 如何在下拉框顶部显示下拉列表(始终)
- android - 在 ViewModel 之间共享数据
- elasticsearch - 为什么拼音搜索比普通匹配查询慢得多
- scala - 使用scala spark将参数传递给sql字符串三元组
- hyperledger-fabric - Hyperledger Fabric - 如何更改链码的集合配置?