Search code examples
gitrebasegit-revertgit-merge-conflict

Reverted all my commits on branch still getting conflicts on rebase


I was working on a feature branch so long because of sick leave that the origin/develop branch is way out of sync with my feature branch.

Since I had a small amount of changed rows but in many classes, I decided to just revert all my changes in that feature branch, push and then rebase origin/develop to my feature branch to avoid human error in solving the conflicts on multiple classes and just add my changes manually after it.

Then I checked out to origin/develop, ran git pull, checked back to my feature branch and ran git rebase origin/develop.

That rebase still has conflicts with my branch. How is this possible and what should I do to get to my original goal? To have a clean slate on the feature branch to safely get all the changes from origin/develop?

I get this in git bash:

Patch failed at 0001 DEV-1234 Initial commit
Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".

So it apparently gets the conflicts in the initial commit and doesn't get to the reverted state yet at that point. Should I just skip that commit with git rebase --skip?

Or, as I'm OK with not having ANY of my changes on the branch left at this point, I can just skip the initial commit AND the reverting commit on my branch so the rebase just cleans the slate by itself.


Solution

  • It seems that in my case, as I didn't want any of my changes being left in my feature branch I could just rebase origin/develop into my feature branch and just skip all my commits in that rebase. No conflicts and a clean slate. I repeat, do this ONLY if you WANT to get rid of your changes in that branch.