Home > front end >  Why are changes indicated by Git after copying a repo between Windows and Linux machines?
Why are changes indicated by Git after copying a repo between Windows and Linux machines?

Time:09-17

I have a project repository on a server with no access to internet. I used WinSCP to transfer that repository to my windows machine and then do a pull and push to GitHub. In this moment, when I execute "git status", everything is clean and up-to-date. Then, I copied this repository back to the Ubuntu machine using WinSCP using the following setting:

enter image description here

when I run "git status" on the Ubuntu machine. I see that 6 files are modified in the working directory and are waiting for being added to staging area!!

How it is possible that a repository that is clean on Windows, is not clean on Ubuntu? Can it be related to line ending? if yes, why it happened only for 6 out of 50 files?

CodePudding user response:

Set the autocrlf to the desired value:

How autocrlf works:

core.autocrlf=true:    core.autocrlf=input:      core.autocrlf=false:
                                           
       repo                     repo                    repo
    /        \               /        \              /        \
crlf->lf    lf->crlf     crlf->lf       \          /            \      
 /              \        /                \      /                \

Yet another way to show how autocrlf works

1) true:             x -> LF -> CRLF
2) input:            x -> LF -> LF
3) false:            x -> x -> x

CodePudding user response:

Thanks to @isherwood. I just checked git config and I realized that line endings are not managed automatically by git.

Thus, I ran the following command and now the problem is solved:

git config --global core.autocrlf true
  • Related