How to change git state behavior by showing modified files that ultimately fail to execute?

I work in a production environment only for windows, and developers use all kinds of tools to edit their files. We use .git along with atlassian glass for the version of our code. I like almost all of this.

I recently ended up fighting a long and hard fight to wrap my head around how and why git interprets line endings and what core.autocrlf does. We decided to use core.autocrlf true , and all this is almost good.

I LOVE to know how to change this git status behavior:

  • I have a file with a CRLF line ending.
  • I change line endings to LF

     $ git status On branch somebranch 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: Src/the_file_i_changed_to_LF.js 
  • But then...

     $ git commit -a warning: LF will be replaced by CRLF in Src/the_file_i_changed_to_LF.js. The file will have its original line endings in your working directory. On branch somebranch nothing to commit, working directory clean 

For this:

  • I have a file with a CRLF line ending.
  • I change line endings to LF

     $ git status On branch somebranch nothing to commit, working directory clean 
  • which makes sense, because in any case nothing will be done.

Is it possible?

I believe the possible duplicate does not contain the answer I'm looking for. I would like to emphasize that I (I think) know what my installation of core.autocrlf true does and wants to keep it that way. I'm interested in either not detecting changes in git status , which in any case will not be fixed, or understanding why this is not possible.

+7
git windows core.autocrlf end-of-line
source share
1 answer

When you set core.autocrlf true , all files in your working directory will have the end of the CRLF line (less than the actual line ending in the repository). For most Windows users, this is good enough.

From your question, I understand that you want your working directory files (= local file) with LF . So here you should use core.autocrlf input . This will give you the exact line that ends the same way as in the repository (but at the same time all checks will be performed using LF ).

More on the difference between true, false, input in this.

+1
source share

All Articles