JillAndMe
JillAndMe

Reputation: 4551

How can I accept all current changes in VSCode at once?

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

Answers (8)

gndps
gndps

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

saurabh Singh
saurabh Singh

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.

you can see image here

Upvotes: 406

Shiqing
Shiqing

Reputation: 47

After accepting all upcoming changes, I have to unstage all changes and stage the changes again to make it work enter image description here

Upvotes: -2

Dami Emmanuel
Dami Emmanuel

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

Yaki Klein
Yaki Klein

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

Select list of files

Right click and choose Accept all incoming

Click File and then Save All

Upvotes: 155

Felix H.
Felix H.

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

AhmadYo
AhmadYo

Reputation: 476

  1. Select all files in Merge Changes section.
  2. Choose Open File from right click menu. It opens all files.
  3. Select all files again.
  4. Choose appropriate menu from right click. eg. Accept All Current.
  5. Choose Save All from File menu.

Upvotes: 4

komoLei
komoLei

Reputation: 429

Select target file, right click and choose 'Accept All Incoming'.

Screenshot of described step.

Upvotes: 41

Related Questions