I was doing some work at home over the weekend and used git to merge code changes back to my office computer (connected via a vpn) and found some very ugly merge problems.
First of all the merge should have been very clean as everything was committed at the office on Friday and I only made changes to my home computer on Saturday and Sunday. But when I pulled the changes to my office computer I ended up with a ton of merge conflicts.
I cleaned up the merge conflicts, but then I found that many of the files (from what I can tell any file that I changed over the weekend) had <<<<<<< HEAD" and ">>>>>>> D1/master
throughout the 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 was able to fix the code using kdiff
by comparing with the source code copied from my home computer, but this just seems completely messed up.
Any ideas what is going on?
Often, merge conflicts happen when people make different changes to the same line of the same file, or when one person edits a file and another person deletes the same file. Make sure you both have clean branch to start. Whenever some have to push its commit, first stash their changes if present.
I encountered the same problem when Windows files where merged into my Linux repo, so that was a CRLF issue. I could finally fix that with the help of this answer. IIRC this had to be done before merging, but it's been a while and honestly I forgot to write it down...
I've had a problem like this come up when going from Windows to *Nix and back due to their different treatment of newline characters. Git might be picking up on those differences and for whatever reason failing to merge.
Maybe try --ignore-space-at-eol
?
Edit:
White space actually does matter when merging. It might not matter in your exact case, but there are contexts where it might make a difference. This question seems to address what should be done to resolve the conflicts much better than I ever could.
This sounds like the CRLF problem while merging: it sparked off a recent discussion here. You might might also want to try to build a reduced case with a few files to find out what exactly is causing this problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With