1

I am trying to merge changes from a colleague into my local repository but git keeps on complaining that I have modified the file and that my changes will be overwritten ("error: Your local changes to the following files would be overwritten by merge").

If I compare my file with the HEAD using egit, it says that nothing has changed (whitespaces are not ignored).

If I now type

git diff HEAD -- myfile

it says that the file has completely changed. (I have removed the entire previous content of the file, and then re-added the entire new content).

My file contains XML but the extension of the file is ".inspector".

My .gitattributes file contains the following:

* text=auto
*.fib text
*.inspector text
*.vm text
*.palette text
*.owl text
*.shema text
*.dict text

and in my git configuration I have the following information (plus email, name and branch/remotes stuffs):

core.autocrlf=true
core.trustctime=false
core.repositoryformatversion=0
core.filemode=false
core.logallrefupdates=true
core.autocrlf=true

I am working on Windows with git 1.7.5.1

I checked this question but it did not work for me.

I also tried to do

git checkout 1.5 -- myfile

but the problem remained.

The github repository (if it can be useful to anyone) is located here: https://github.com/agilebirds/openflexo

And the problematic file is the following: https://github.com/agilebirds/openflexo/blob/1.5/flexodesktop/modules/flexoworkfloweditor/src/main/resources/Inspectors/WKF/Role.inspector which has been recently edited by my colleague (who works on a Mac).

If any additional information is needed, don't hesitate to ask, I will gladly provide it.

Community
  • 1
  • 1
Guillaume Polet
  • 47,259
  • 4
  • 83
  • 117
  • Either commit or stash your changes to your local repo. This is how git works. In order to merge, your local repo must be clean. http://stackoverflow.com/questions/9588111/how-do-you-git-fetch-then-merge-error-your-local-changes-to-the-following-fil – Jeff Jan 31 '13 at 16:39
  • @Jeff while this would indeed work, it will pollute my git history with unnecessary commits (or create unneeded stashes). Moreover, this issue happens quite regularly, so I would rather solve the problem upfront, rather than work around it. – Guillaume Polet Jan 31 '13 at 16:41
  • @GuillaumePolet you can drop the stash once you don't need it any more – umläute Jan 31 '13 at 16:45
  • @umlaeute yes but I don't want to do that. These are workarounds which I am aware of, but I would like to fix the issue once and for all. I am pretty sure I have done something incorrectly and that git should not report my file as modified. – Guillaume Polet Jan 31 '13 at 16:48
  • This looks an awful lot like a line ending issue. Can you show us the output of `file yourfile` and `git show origin/branch:yourfile > tempfile`, `file tempfile`. – Chronial Jan 31 '13 at 18:27
  • @Chronial Both of them report `XML document text`. My other colleague has `core.autocrlf = input` in his git configuration – Guillaume Polet Jan 31 '13 at 18:33
  • @Chronial after reviewing this with my colleague, it appears that it has set twice the value core.autocrlf. Once in the global git configuration with `core.autocrlf = input` and the second time, in the repository configuration, with `core.autocrlf = false`. Could it be the root of my issue? – Guillaume Polet Jan 31 '13 at 18:48
  • @GuillaumePolet I think you may be trying to fix something that really isn't broken. This is how Git is designed to work. Perhaps you should be working in another branch that won't end up merging into master. More of an experimental branch. That way you can merge your colleagues changes into your local master without these conflicts. Does that make sense? – Jeff Jan 31 '13 at 21:22
  • @Jeff Sorry, I am not sure I understand you. AFAIU Git, if a colleague (using whichever platforms) changes a file that I don't change, it should merge itself without any issues. I believe there is a problematic configuration somewhere that I would like to solve. – Guillaume Polet Jan 31 '13 at 22:37
  • @GuillaumePolet Yes, this is probably the root of your issue. Try running `git config core.autocrlf = true` in your repo (if you are on windows). But you should now that core.autocrlf is old and kind of deprecated. I explained the correct way to it here: http://stackoverflow.com/a/13154031/758345 – you should use that in your team. – Chronial Jan 31 '13 at 22:42
  • @Chronial Why does github still advises to use core.autocrl (pure wondering)? Anyway, will this (the answer in your link) solve all issues in all platforms? While almost any decent program can handle both CRLF and LF without issues, many of them still produces CRLF on Windows and LF on Unix/Linux platforms. – Guillaume Polet Feb 01 '13 at 00:05
  • @GuillaumePolet You are correct. I misunderstood the question to mean that you had made changes to the files and wanted to merge in your colleagues changes with doing a commit. – Jeff Feb 01 '13 at 01:22
  • @GuillaumePolet because it’s easier to set globally. But the *proper way to it*™ is to store the line ending convention in the repo. And yes, this will solve all issues on all platforms. – Chronial Feb 01 '13 at 06:27
  • @Chronial Ok, good to know. Thanks for all the explanations. – Guillaume Polet Feb 01 '13 at 08:25

0 Answers0