0

I have the same GIT repository cloned in Windows and Linux. Sometimes I switch from Windows to Linux and everything goes fine and this mean unchanged files remain unchanged. Now I have switch back to Windows from Linux, I pull all my work and run a composer update which didn't modify any tracked files. I must say the same command from Linux doesn't mark the files as changed.

How do I know? Because the content is exactly the same (see the images below).

this is a file comparison using PhpStorm IDE

this is a file comparison using Smargit

As you can see in both pics and using different applications the file remains the same however Git is tracking them as changed. Then I remember this useful post How do I make Git ignore file mode (chmod) changes? and after read it back and forth I went to the repository config file .git/config and surprise the value was already there:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true

So I am completely lost and don't know what to do to avoid such behavior. Can any give me some ideas? Any clue?

ReynierPM
  • 17,594
  • 53
  • 193
  • 363
  • Run this command: `git config -l | grep autocrlf`, do you get any output, if so what? – LightBender Sep 09 '17 at 02:39
  • @LightBender I am running Windows don't know if that command will works over all the place – ReynierPM Sep 09 '17 at 12:48
  • You can run it in git bash, or you can just run `git config -l` and use an organic search to find the autocrlf setting. :) – LightBender Sep 09 '17 at 12:49
  • How did this end up? I am facing the same issue. I have dual boot, and I have started working on Linux, but git is showing unchanged files as changed... I tried setting `filemode=false` as in the linked answer but this didn't work. – Karthik Thrikkadeeri Jan 28 '22 at 05:23
  • @LightBender for me that command is not resulting in any output. – Karthik Thrikkadeeri Jan 28 '22 at 05:24
  • @KarthikThrikkadeeri, no output (assuming you're running it from either `git bash` on windows or normal `bash` on linux) means that you don't have `autocrlf` set. This is usually something that happens when you set up on windows and turn on autoCRLF handling when you install it. It converts `\n` (unix line endings) to `\r\n` (windows line endings) when a file is checked out and converts them back when committing. Misconfiguration causes all kinds of difficulty because it's trying to compensate on compare. My advice is to turn it off and always use unix line endings natively for development. – LightBender Jan 28 '22 at 13:38
  • @LightBender I'm very new to Linux so just some clarifications. I ran the command from the Linux terminal. I don't quite follow what you refer to when you say "set up on windows". But when making commits (I am using git in RStudio) I see that line endings haven't been changed--I mean the git diff outputs this statement. If I plan to work only from Linux from now, what do you recommend I do? And how would this work if I end up switching between the two OSs? – Karthik Thrikkadeeri Jan 29 '22 at 03:53

0 Answers0