I'm currently in the middle of a lengthy rebase going through a dozen or so commits. I've structured things in my dev process such that only the changes from HEAD
is what I want to keep - all other conflicts (e.g. commit hash b06a1dd
) should be deleted.
Is there a way to simply remove all changes related to the >>>>>>> b06a1dd
and keep the changes that Git will label <<<<<<< HEAD
in one fell swoop, so I don't have to keep typing git rebase --continue
, deal with more conflicts from more commit hashes, and only keep the HEAD
changes?
If you are willing to start the rebase over (git rebase --abort
), then this should do what you need:
git rebase -X ours upstream
where upstream
is the branch you are rebasing onto.
As noted in this answer and elsewhere, the ours
vs. theirs
labels are slightly more confusing for rebasing than for merging. After starting a rebase, Git creates an anonymous branch and starts applying commits to it. Since ours
means "keep changes from the current branch", that current branch will be HEAD
, which contains upstream
and any changes already applied by rebase
.