Fix conflicts when git drop a co
2021-10-11 本文已影响0人
JaedenKil
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.