美文网首页Git
Fix conflicts when git drop a co

Fix conflicts when git drop a co

作者: JaedenKil | 来源:发表于2021-10-11 15:35 被阅读0次

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.

相关文章

网友评论

    本文标题:Fix conflicts when git drop a co

    本文链接:https://www.haomeiwen.com/subject/yfwloltx.html