Auto Resolve Git Rebase, Take Incoming Change
It's a nightmare that clears up quickly. You rebase, and it produces a merge conflict. Instead of looking at the file contents, you decide to simply take the incoming changes.
The Scenario
You're on your feature branch:
git checkout myfeatureYou try to merge the main branch:
git rebase mainThis produces conflicts. Who has time to edit conflict markers?
Accept Changes from main
In this scenario, you know main is pristine. If there is a conflict, you'd like to just accept main's authoritative version of things.
First, identify the path from git root to the file that is in conflict. Use the git checkout --ours command:
git checkout --ours path/to/fileInConflict.js
git add path/to/fileInConflict.jsYou've now automatically resolve the conflict markers. Continue with:
git rebase --continueYours, Mine and Ours
To me, the option for this command is backward. This is the option legend matched with the branches in this scenario:
--oursismainbranch--theirsismyfeaturebranch
What other methods do you use to easily resolve your git conflicts?