1

We are two people working on a git repository. Almost every time my colleague pushes stuff to the repository, when I pull them in my local repo, a lot of files that I have never touched (or even opened for that matter) become conflicted.

Can anyone suggest a way to investigate it?

bmenekl
  • 115
  • 5
  • maybe everytime he's using this, git add src/ , I'm not sure , but I think I had this problem once – The Coder Feb 07 '15 at 08:28
  • 1
    Are you both working on the `master` branch? Do you have other branches? Has either of you rebased or amended changes that have been pushed? – halfer Feb 07 '15 at 08:29

2 Answers2

2

Check the exact nature of the diff: it might involve eol (end of line) style (\n\r vs \n)

git diff --word-diff-regex=.

In that case, make sure your:

  • git config --global core.autocrlf is set to false
  • your editor respect eol style and don't attempt to change it.
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I am using MacOs and my core.autocrlf is set to input while my colleague is using Windows and has his core.autocrlf set to true (as is the [suggestion of git-scm](http://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#Formatting-and-Whitespace)). We have two different suggestions it seems :) – bmenekl Feb 07 '15 at 09:21
  • @bmenekl always set core.autocrlf to false. Everywhere. For everybody. – VonC Feb 07 '15 at 09:25
  • @bmenekl see also http://stackoverflow.com/a/2354278/6309 and http://stackoverflow.com/a/17628353/6309 – VonC Feb 07 '15 at 09:27
  • @bmenekl in some cases you might have to edit the .gitattributes file also http://stackoverflow.com/a/15161420 – foufos Oct 24 '15 at 16:40
1

One way to try fixing this problem is for both of you to clone the repo to a different local folder, and then committing in a test change each. If you both push and pull and it is OK, it may be that one of you tried to rewrite history by rebaseing or amending pushed commit(s).

If those test commits work, you can commit and push any pending changes each of you have, and point your editor to the new repo. I tend to recommend not deleting your old one for a few days, in case there is a change you forget to copy!

halfer
  • 19,824
  • 17
  • 99
  • 186