Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git status shows modifications even with autocrlf=false

I'm experiencing the same issues as in this question: git status shows modifications, git checkout -- <file> doesn't remove them

Git continues to show working directory modifications, even with git config --global core.autocrlf false:

E:\_dev\github\Core [master +0 ~93 -0]> git config --get-all core.autocrlf false false 

(Note that I've even set the --system setting to be false)

Why does it appear that Git is still modifying my end of lines?

Attempts to get rid of modifications

Baseline

E:\_dev\github\Core [master +0 ~93 -0]> git status # On branch master # Changes not staged for commit: #   (use "git add <file>..." to update what will be committed) #   (use "git checkout -- <file>..." to discard changes in working directory) # #       modified:   tools/StatLight/StatLight.EULA.txt ... more changes ... no changes added to commit (use "git add" and/or "git commit -a") 

git checkout -- .

E:\_dev\github\Core [master +0 ~93 -0]> git checkout -- . E:\_dev\github\Core [master +0 ~93 -0]> git status # On branch master # Changes not staged for commit: #   (use "git add <file>..." to update what will be committed)  #   (use "git checkout -- <file>..." to discard changes in working directory) # #       modified:   tools/StatLight/StatLight.EULA.txt ... more changes ... no changes added to commit (use "git add" and/or "git commit -a") 

Occasionally this will have an effect in an odd way:

E:\_dev\github\Core [master +0 ~628 -0]> git checkout -- . E:\_dev\github\Core [master +0 ~361 -0]> git checkout -- . E:\_dev\github\Core [master +0 ~93 -0]> git checkout -- . E:\_dev\github\Core [master +0 ~93 -0]> git checkout -- . E:\_dev\github\Core [master +0 ~93 -0]> git checkout -- . 

git reset --hard

E:\_dev\github\Core [master +0 ~93 -0]> git reset --hard HEAD is now at 11a7f9a Merge pull request #8 from RemiBou/master E:\_dev\github\Core [master +0 ~93 -0]> 

git add .; git stash; git stash drop

E:\_dev\github\Core [master +0 ~93 -0]> git add . ... warnings .... warning: CRLF will be replaced by LF in tools/StatLight/StatLight.EULA.txt. The file will have its original line endings in your working directory.  E:\_dev\github\Core [master +0 ~93 -0]> git stash Saved working directory and index state WIP on master: 11a7f9a Merge pull request #8 from  RemiBou/master HEAD is now at 11a7f9a Merge pull request #8 from RemiBou/master  E:\_dev\github\Core [master +0 ~93 -0]> git stash drop Dropped refs/stash@{0} (de4c3c863dbad789aeaf563b4826b3aa41bf11b7)  E:\_dev\github\Core [master +0 ~93 -0]> git status .\tools\StatLight\StatLight.EULA.txt # On branch master # Changes not staged for commit: #   (use "git add <file>..." to update what will be committed) #   (use "git checkout -- <file>..." to discard changes in working directory) # #       modified:   tools/StatLight/StatLight.EULA.txt # no changes added to commit (use "git add" and/or "git commit -a") 
like image 225
codekaizen Avatar asked Jun 12 '12 22:06

codekaizen


People also ask

Does Gitattributes override Autocrlf?

gitattributes not override core.

How do I remove unchanged files in Git?

Remove every file from Git's index. git rm --cached -r .

What does Autocrlf true do?

autocrlf . This is a similar approach to the attributes mechanism: the idea is that a Windows user will set a Git configuration option core. autocrlf=true and their line endings will be converted to Unix style line endings when they add files to the repository.

What is Autocrlf in Git?

autocrlf command is used to change how Git handles line endings. It takes a single argument. On macOS, you simply pass input to the configuration. For example: $ git config --global core.autocrlf input # Configure Git to ensure line endings in files you checkout are correct for macOS.


1 Answers

This seems like a bug in msysgit indeed. As a workaround, try creating a .gitattributes file containing

* -text 

This will tell git not to perform EOL conversions on any files.

like image 115
Brecht Machiels Avatar answered Oct 06 '22 14:10

Brecht Machiels