198

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?

PeterJames
  • 1,137
  • 1
  • 9
  • 17
JillAndMe
  • 3,989
  • 4
  • 30
  • 57
  • If someone is looking for an answer to do this in Visual Studio (instead of VSCode), take a look at this answer: https://stackoverflow.com/a/74605102/8644294 – Ash K Nov 28 '22 at 18:48

6 Answers6

357

Its 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

Misha Akopov
  • 12,241
  • 27
  • 68
  • 82
saurabh Singh
  • 4,902
  • 3
  • 11
  • 12
125

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

Yaki Klein
  • 3,978
  • 3
  • 37
  • 34
  • 11
    Did not work for me. The conflicts persist even after following the exact same steps. – Prashant Singhal Dec 09 '20 at 08:30
  • 2
    Turns out this only works when only files are selected and their parent directories are excluded. You can select each file holding `Ctrl` key and then choose the option *Select All Changes* from the cascade menu. All the files will open with unsaved changes. To save all the unsaved files at once, do *File > Save All*. – Prashant Singhal Dec 09 '20 at 08:37
  • 1
    If you still see conflicts - `Save all Files` – Deepak Mahakale May 19 '21 at 07:17
  • Doesn't work for me when I have 1000+ files in various directories having conflicts. Clicking the _Accept all current_ option doesn't do anything (_Accept all incoming_ works though). I had to select files in groups of about 30 files and select the option, followed by _Save all_ and _Close all_ – ManSamVampire Aug 04 '22 at 14:49
  • I have one conflicting file. It's binary (don't judge) so I can't preview changes. Right click / select that one file, "Accept all Incoming" does nothing. Same with command palette action. – dudeNumber4 Aug 09 '22 at 15:32
  • Be careful, don't select the "Deleted" files. If the files you selected contains "deleted" files, it will make "Accept all incoming" do nothing. – Lin Du Sep 16 '22 at 08:05
37

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

Screenshot of described step.

grg
  • 5,023
  • 3
  • 34
  • 50
komoLei
  • 381
  • 3
  • 2
27

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.

Felix Htoo
  • 874
  • 12
  • 15
  • After running this command, "Unmerged paths" remain until running `git add --all` which is very confusing... because they are... merged. – dudeNumber4 Aug 09 '22 at 15:38
4
  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.
AhmadYo
  • 334
  • 3
  • 6
1

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
Emmac
  • 2,928
  • 2
  • 15
  • 22