我是GitHub存储库https://github.com/plison/opendial的管理员。我想减少存储库中的提交数量,因为存储库已经有几千次提交,其中许多都是轻微的调试更改,很容易被压缩在一起(特别是几年前的那些)。 p> 因此,我试图应用变基才能将我的部分提交压缩在一起。但是,我遇到了以下问题:
git rebase -i HEAD~10
,我在交互式编辑器中获得了相当多的提交行(超过10个)。可能是什么原因?我该如何解决这些问题?应该注意的是,存储库是从Google Code上托管的先前(SVN)存储库自动导入的。转换似乎到目前为止运行良好,但我想知道为什么我在尝试重新提交我的提交时会出现这些错误。
答案 0 :(得分:43)
提醒自己如何解决这个问题:
错误消息不是很有用。如果您输入
git rebase --continue
您意识到错误是由于git无法自行解决的合并冲突,需要您的帮助。
在您喜欢的编辑器/ IDE中解决合并冲突(提示:这应该以i开头并以ntelliJ结尾)
用
标记分辨率git add .
如果所有冲突都已解决,您应该看到如下内容:
(all conflicts fixed: run "git rebase --continue")
继续使用
继续你的变基git rebase --continue
希望你的rebase现在应该成功
git status
所示:
On branch feature/DIG-19302-Upgrade-mockito-v2
Your branch is behind 'origin/feature/your-feature-branch' by 2 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
nothing to commit, working directory clean
不要做git pull 。如果这样做,您将只覆盖合并冲突。而是使用
将合并冲突解决方案推送到分支git push --force
你已经完成了!您的git日志现在应该只显示1个提交(这是您刚刚执行的强制更新)
答案 1 :(得分:16)
The history of your project seems to contain a number of merge commits recently (presumably you made those). The presence of merge commits in what you want to interactively rebase usually causes problems. (An interactive rebase pretty much assumes a linear history, but merge commits are not linear.)
Your project history also somehow seems to have two parallel histories that are merged together in commit 11b3653 (use a tool like gitk
or tig
to see this, it's not shown well on Github's web interface).
I would suggest that you attempt to first flatten your history to get rid of the parallel histories, and to remove the merge commits. Then, once you have a strictly linear history, you can set about rewriting the history to remove all the debugging churn.