Git merge: why am I getting a lot of merge conflicts after changing the source on both Linux and Windows?

Over the weekend, I worked at home and used git to merge code changes with my office computer (connected via vpn) and found some very ugly merging problems.

First of all, the merger should have been very clean, since everything was done in the office on Friday, and I only made changes to my home computer on Saturday and Sunday. But when I pulled the changes onto my office computer, I ended a ton of merge conflicts.

I cleared the merge conflicts, but then I found that many files (from what I can tell any file that I changed over the weekend) had <<<<<<< HEAD" and ">>>>>>> D1/master for all files. For example:

 diff --git a/web/Web.Controller/Helpers/FormsAuthentication.cs b/web/Web.Controller/Helpers/FormsAuthentication.cs index 8571f53..4a9c9fc 100644 -- a/web/Web.Controller/Helpers/FormsAuthentication.cs ++ b/web/Web.Controller/Helpers/FormsAuthentication.cs @@ -10,7 +10,10 @@ /// </summary> public class FormsAuthenticationUtility : IAuthenticationUtility { <<<<<<< HEAD ======= >>>>>>> D1/master #region IAuthentication Members /// <summary> 

I managed to fix the code with kdiff by comparing it with the source code copied from my home computer, but it just seems to be completely corrupted.

Any ideas what is going on?

+6
git merge conflict
source share
3 answers

I ran into the same problem when Windows files merged into my Linux repo, so this is a CRLF problem. I could finally fix this with this answer . IIRC needed to do this before the merger, but some time passed, and honestly, I forgot to record it ...

+4
source share

I got this kind of problem when you switch from Windows to * Nix and back because of their different relationship to newline characters. Git can pick up these differences and for some reason cannot merge.

Perhaps try --ignore-space-at-eol ?

Edit:

White space really matters when merged. It may not matter in your particular case, but there are contexts where it may matter. This question seems to be about what needs to be done to resolve conflicts much better than ever.

+1
source share

This seems like a CRLF merge issue: this has sparked a recent discussion here . You might also want to try creating a smaller case with multiple files to figure out what exactly is causing this problem.

+1
source share

All Articles