Fix conflicts when git drop a commit

While trying to drop a commit 6f34289, there is a conflict:

$ git log --oneline -10
58f83bb (HEAD -> dev, origin/dev) xxx
1dce24f xxx
cdfb55c xxx
3579e48 xxx
8cc184a xxx
6f34289 xxx
c795e92 xxx
...
git rebase -i c795e
// Change to "drop" for "6f34289"

error: could not apply 8cc184a... xxx

So abort the rebase:

git rebase --abort

And run rebase -i again to drop the commit, but keep our changes:

git rebase -i -X ours c795e

Successfully rebased and updated refs/heads/dev.

We can add -X ours or -X theirs to keep some changes and discard others.
If anything goes wrong, just run git reset --hard xxx to roll back, as if the rebase has never been executed.

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 以下笔记主要参考gitgot,大致了解git使用和原理。 第一部分我们从个人的视角去研究如何用好Git,并且揭示G...
    carolwhite阅读 7,038评论 0 1
  • git作为时下最流行的代码管理工具,Git权威指南总结了十条喜欢Git的理由: 异地协同工作; 现场版本控制; 重...
    古斟布衣阅读 5,796评论 0 12
  • 0. 引言当你提交代码进行代码审查时或者创建一次pull request (这在开源项目中经常发生),你的代码在被...
    pansly阅读 47,705评论 5 9
  • 分离头指针 当前分支图 切换到之前的某一次提交 执行命令 提示,当前位于“分离头指针”状态 分支图 注意 在分离头...
    F嘉阳阅读 3,146评论 0 0
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 13,448评论 0 23