Even though there are already great answers here, I wanted to post this answer to document how to resolve all merge conflicts in Visual Studio 2022 (in favor of our changes as an example).
If instead, you want to accept incoming changes (their changes) as asked in this question, just replace ours
in Step 6 below with theirs
. It's as simple as that.
Summary of what I'm doing here:
Merge dev into my branch and while doing that if there are any merge conflicts, take changes from my branch.
(After this is done, I'll create a PR to finally push the changes from my branch to dev).
Step 1
Checkout the branch where you want to merge dev
into by going to 'Manage Branches' and double clicking your branch name. In my case, it's feature\InterimBranchToDev2-AshK
.
Step 2:
Right click dev
and click Merge 'dev' into 'feature/InterimBranchToDev2-AshK'
Step 3:
You'll see a ton of merge conflicts! 😲
Now it's very tedious to right click each of those files and click Keep Current (feature/InterimBranchToDev2-AshK)
, so let's Abort
this and take care of this using command line.
Step 4:
Hit Abort
Step 5:
Open cmd
Step 6:
Type git merge --strategy-option ours --no-commit dev
and hit enter
What this basically means: "Merge dev into current branch and if there are any merge conflicts, take version from current branch, and also don't commit the merge yet".
This will be the output:
Automatic merge went well; stopped before committing as requested
Step 7:
Now go to Visual Studio, conflicts are nicely taken care of and you can enter your message and commit: