Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Shows Random Files as Modified After Clone; Can't Discard Them

Tags:

git

github

As soon as I clone a certain repo on my macbook pro, I immediately see files as modified in that repo. I've tried git pull, git checkout, git reset, nothing seems to make these supposedly modified files go away. I've been using git for a while and have never seen this before. What could possibly be causing it?

like image 525
Eli Avatar asked Aug 30 '12 21:08

Eli


1 Answers

There is a configuration file that marks certain types of source files as text, for which newlines will be converted. There's either a .gitattributes file in the root of the repository, or a global ~/.gitattributes in your home directory.

You can do two things:

  • modify the .gitattributes configuration so that files aren't marked as text anymore
  • commit the proposed changes so that the repository becomes consistent with the specification; I'd recommend this solution

I'd say that the intention was to properly let git handle newlines, so someone added the configuration in .gitattributes after some files were committed with the Windows CRLF endlines, and when that happens, git doesn't automatically fix the existing files that were already checked out in the working tree. But a new clone will get those files into the working tree anew and automatically fix them, so git will complain next time you compare the working tree with the index.

like image 115
Sergiu Dumitriu Avatar answered Oct 25 '22 09:10

Sergiu Dumitriu