Reputation: 4551
I tried to merge one file with another file, but there are many HEADs with Accept Current Change | Accept Incoming Change | ...
Is there a way to accept all current changes at once?
Upvotes: 233
Views: 226382
Reputation: 821
To mark conflicts as resolved, after accepting incoming, you need to run:
git add $(git diff --name-only --diff-filter=U)
You can add this as an alias
git config --global alias.mark-resolved '!git add $(git diff --name-only --diff-filter=U)'
and then use
git mark-resolved
Explanation:
This command uses git diff
to find all unmerged paths (--diff-filter=U
) and then stages them using git add.
This will mark the conflicts as resolved without impacting other files.
If you want to add all files, you can use git add -u
which tells Git to stage all changes (including unmerged paths) in the index.
Upvotes: 0
Reputation: 5730
It's very easy just go to vs code and press Ctrl+shift+p (command palette) or go to view and open command palette manually and type "merge" in your command palette, now you can see the Accept all current changes.
Upvotes: 406
Reputation: 47
After accepting all upcoming changes, I have to unstage all changes and stage the changes again to make it work
Upvotes: -2
Reputation: 3173
Unfortunately, none of the answers here worked for me. However, I was able to accept all incoming changes by running these commands manually.
I was in the conflict state at this point so I had to abort the merge and then pull all "their" (incoming) changes.
git merge --abort
git pull -X theirs
Upvotes: 2
Reputation: 4376
select the list of files to resolve from the MERGE-CHANGES section, then right-click your mouse and select Accept all incoming. That should do the trick for all files.
You will need to save the updated files once the conflicts are resolved. Click File and then Save All
Upvotes: 155
Reputation: 1112
As For VSCode MacOS, I've done Accept All Incoming
from Merge Changes
section, but it didn't affect all (that may be a bug, or I don't know why).
So, I used the conventional way with command line, and it worked.
For accepting all incoming changes,
git checkout --theirs .
or
For accepting all current changes,
git checkout --ours .
P.S. Hope it helps for those who need to solve merging conflict first in any case.
Upvotes: 41
Reputation: 476
Merge Changes
section.Open File
from right click menu. It opens all files.Accept All Current
.Save All
from File
menu.Upvotes: 4