Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
897 views
in Technique[技术] by (71.8m points)

intellij idea - how to find crlf line separators with git?

as I want to commit to git using intellij, I get a message

You are about to commit CRLF line separators to the Git repository

and I am given 2 options:

  • fix and commit (runs git config --global core.autocrlf)
  • commit as is

I would like to see where those line separators are before I do anything else.

How can I do that with git or intellij? (solutions using only git are preferred).

question from:https://stackoverflow.com/questions/24603649/how-to-find-crlf-line-separators-with-git

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You could use git grep via the command line to search for files containing the windows style newline characters.

Using the git bash you can find all files which contain a character via the following command (bash only!):

git grep -Il $'
'

Or alternativly (which should work for all shell types - except windows ones):

git grep -Il '<CTRL + M>'

This will actually display as a newline in your shell, but as long as you wrap it into quotes it will work.

And finally for the windows CLI (tested with CMD and PowerShell):

git grep -Il "
"

Used options

  • -I excludes binary files from the match
  • -l shows only the file names with matches, rather than all matches

Also, if you want to restrict your search on a number of files you can use the --cached option, which will only search in files you have on your index.

You can read the documentation for more information.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...