2

I work with GIT on Linux, and my colleague works with GIT on Windows.

I commited some changes to a file, and my colleague commited some other changes to that file.

My colleague pushed, and I pulled.

Now, my entire file is a one big conflict:

<<<<<<< HEAD
...
[my version]
....
=======
...
[colleague's version]
...
>>>>>>> branch 'master' of https://github.com/rothariel/aimnegochat.git

What can I do? How can I merge the changes?

Erel Segal-Halevi
  • 33,955
  • 36
  • 114
  • 183

3 Answers3

3

From this article in github you can overcome such problem

the suggested eol is \n, you can use this to autoconvert

git config --global core.autocrlf input
# Set this setting on OSX or Linux

git config --global core.autocrlf true
# Set this setting on Windows

Have a look at the example what to do next.

https://help.github.com/articles/dealing-with-line-endings

Redian
  • 334
  • 1
  • 7
  • 2
    This doesn't exactly answer the question of "what do I do now?" This answers the question "How do I avoid this in the future." See http://stackoverflow.com/questions/861995/is-it-possible-for-git-merge-to-ignore-line-ending-differences and http://stackoverflow.com/questions/1522933/clarifying-clearing-up-line-ending-issues-in-git for getting yourself out of the current mess, then get your windows friends follow this answer for the future. – Dan Feb 07 '13 at 15:57
  • You are right, I need a solution for now. The first link you mentioned explains how to do the merge, the problem is I already did the merge... The second link explains how to fix the repository, but not how to rescue the merged file... – Erel Segal-Halevi Feb 07 '13 at 18:23
  • Rescue the merged files ? git checkout to a previous state then perform the merge after you have set the right configurations as in the github article. – Redian Feb 07 '13 at 18:47
1

I had a similar problem:

git merge <master|branch|whatever> -s recursive -Xignore-space-at-eol

Seems to do what I need it to do, but it gave me errors:

error: addinfo_cache failed for path ...

However:

git merge <master|branch|whatever> -s recursive -X renormalize

Seems to do the trick.

I've still got issues with line endings every time i check in files. Something in the commit / merge process is switching my line endings back to what they shouldn't be.

I've tried messing around with the

git config --global core.autocrlf <true|input|false>

settings, but it doesn't seem to resolve the fact that something is changing my line endings in the git tool chain.

Owl
  • 1,446
  • 14
  • 20
-1

You need to merge the changes your colleague has done with your changes. Simply edit the file and add to index. You can commit your changes after that.

ogzd
  • 5,532
  • 2
  • 26
  • 27
  • 1
    Well, that's exactly what I asked... How can I merge the changes? I don't even know what was the colleague's changes nor remember my changes... Usually the merge happens automatically, is there a way to make that happen in this case? – Erel Segal-Halevi Feb 07 '13 at 15:21
  • You don't need to remember your changes or your colleagues changes. `<<<<<< HEAD` and `>>>>>> master` shows which particular area is different between your local and remote branch. You can simply lookup each sentence which are different. Please also take a look at `git mergetool` command. – ogzd Feb 07 '13 at 15:28
  • 1
    The problem is, my entire file is surrounded by these tags (i.e. all my version of the file, from beginning to end, is betweeh the "HEAD" and the "=====", while all my colleague's version of the file, from beginning to end, is between the "=====" and end-of-file. This is because of the end-of-line difference between Linux and Windows. – Erel Segal-Halevi Feb 07 '13 at 17:44