1

I have seen few posts on this here in git but none so far seem to have answer.

I am having following problem. Every time I do a successful git fetch/git merge, I see lots of files listed by git as modified in some way. Some are unstaged, while others are untracked or uncommitted.

So, even though I have not changed them, they show as somehow being modified when I do git fetch and git merge.

This is a problem since now, if I commit and push my changes, all these files appear as modified by me which is wrong.

I am using MacBook for my development, but other dev teams may be using Windows. So, as a first culprit to this I can think off is line endings. I checked on my Mac and git config core.autocrlf shows input, which as I understand should be on Mac.

Checking on Windows, shows git config core.autocrlf as true, which also according to my understanding is correct.

So, assuming the settings above are correct, line endings should not be the problem but I dont know how to confirm that.

Also, I dont know how to fix this issue with files that I have not modified in any way show as modified after I do git fetch and git merge without any conflicts.

So, my questions are

How to confirm that line-endings are or are not culprit behind this issue?

How to fix this issue?

UPDATE

It looks like not only text based files such as cs, txt, xml etc but also binary like png files are marked as modified. So, the issue is not line endings IMO or?

pixel
  • 9,653
  • 16
  • 82
  • 149
  • Are you working in a team using multiple platforms? – evolutionxbox Nov 08 '18 at 00:01
  • Yes, I am but I dont think it is caused by line-endings. Based on my explanation above, line endings should be set properly, at least on my Windows and my Mac. Also, I noticed that also png files are seen as modified by git, so it should not be line-endings that is causing it. – pixel Nov 08 '18 at 00:08

1 Answers1

1

I would really recommend keeping core.autocrlf to false

git config --global core.autocrlf false

That settings would change eol for all files including binaries, which is not good.

Then, since Git 2.16: git add --renormalize .. Check if you have changed files then.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • hey, thanks. Would you mind elaborating bit. I am worried to change that now that I am in the middle of work and have files that I have changed but not pushed to remote. – pixel Nov 08 '18 at 08:09
  • @pixel First commit your changes (and only your changes) making sure the eol is already the right one. Push. Then you can set that configuration and clone again your repo, to check that no files is "automagically" modified. – VonC Nov 08 '18 at 09:56
  • @pixel See also on that same topic https://stackoverflow.com/a/20168775/6309, or https://stackoverflow.com/a/44224929/6309. On the fin-grained details: https://stackoverflow.com/a/17628353/6309 – VonC Nov 08 '18 at 09:57