7

I'm using Git in Visual Studio and suddenly got this conflict on all files screenshot

I can click through each and every conflict and choose Take Source, but since there are 534 conflicts, I would rather do a batch resolve on the command line. What would be the appropriate commands to resolve all these conflicts?

Eivind Gussiås Løkseth
  • 1,862
  • 2
  • 21
  • 35
  • Are they significantly different? – Anubian Noob Jun 06 '14 at 23:26
  • I'm the only developer in the project, and I pushed two changes a few hours earlier. Then Git suddenly is thinking that my local branch has none of the remote changes, so I have to pull all commits from the day the branch was created. I have to say that I haven't got much experience with Git, but I've created a couple of feature branches and synced changes without problems until now. – Eivind Gussiås Løkseth Jun 07 '14 at 08:43
  • All the 500 conflicts are of type add/add, which means that Git thinks the same files are added on both local and remote. I think what I need to do is run a batch resolve to either keep target or take source files on each conflict. I can do that by clicking through each conflict, but I would take a lot of time, so I'm looking for a command to do that for all conflicts in one operation. – Eivind Gussiås Løkseth Jun 07 '14 at 08:50

3 Answers3

3

Check the differences between the conflicts reported by Visual Studio.

It is possible that they are about eol style onle (end-of-line LF vs. CRLF)

You can try setting git config core.autocrlf true/false to see what would work best, but this Q/A page does mention that the Git plugin doesn't seem to respect that setting anyway.


The OP Eivind Gussiås Løkseth adds in the comments:

I'm looking for a command to do that for all conflicts in one operation, because doing it for all 500 conflicts would take a lot of time

As mentioned in "Simple tool to 'accept theirs' or 'accept mine' on a whole file using git", you could, in the root folder of your repo, do a:

git checkout HEAD -- .
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • All conflicts are of type add/add, which means Git thinks all files are recently added in both local and remote. But that's obviously a bug in the tools. I have to either take source or keep target for all conflicts. The files are equal. I'm looking for a command to do that for all conflicts in one operation, because doing it for all 500 conflicts would take a lot of time. – Eivind Gussiås Løkseth Jun 07 '14 at 09:09
  • @EivindGussiåsLøkseth ok, I have added such a command, as well as a link to a question which details that command. – VonC Jun 07 '14 at 09:25
  • Thanks! This was the command I was looking for. I had to do a git commit -m "something..." to commit the merge, and now all the conflicts are gone. – Eivind Gussiås Løkseth Jun 07 '14 at 10:34
0

My advice in such a scenario is to create a 3rd branch and do all the merging there, and then replace the current branch with the third branch when you are sure the merging went as expected. Now, coming to the original question, I have not worked with Visual Studio, but I assume the git command shell in VS would behave the same as the usual git command shell. Could you describe what you are trying to do. Are you tracking a remote branch on which you made local changes and now you are pulling the changes which cause conflicts? Or, are you trying to merge two local branches?

Ashu Pachauri
  • 1,283
  • 10
  • 16
  • I've explained a bit more in a comment to the question now. I'm the only developer in the project. I've synced changes to the branch a lot before this suddenly happened. I haven't switched my local branch, but Git now thinks that my local has none of the commits in the remote, so I have to pull all before I sync my two latest commits. Even though all files are equal, I get merge conflicts on 500 of them. Most of them I haven't touched in several years. – Eivind Gussiås Løkseth Jun 07 '14 at 08:46
0

I know this is old, but I ended up in the same situation. Here's how I solved it:

  1. In the 'merge to' branch, undo / abort the merge.
  2. Back up files that are conflicting.
  3. Remove all the conflicting files (if they are the same on both branches)
  4. Commit the change (removing files)
  5. Do merge
  6. Re-add files Commit

And that should do it.

mcse3010
  • 174
  • 2
  • 10