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:
git config --global core.autocrlf
) 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).
There are two ways to represent a line ending in a source code file. CRLF (carriage return + line feed); or just LF (line feed).
From the main menu, select File | File Properties | Line Separators, and then select a line ending style from the list.
To tell what line endings a file in the repository is using, use git show to extract the file's contents. This will give you the contents without changing the line endings.
Git doesn't expect you to use unix-style LF under Windows. The warning "CRLF will be replaced by LF" says that you (having autocrlf = input ) will lose your windows-style CRLF after a commit-checkout cycle (it will be replaced by unix-style LF). Don't use input under Windows.
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 \r
character via the following command (bash only!):
git grep -Il $'\r'
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 "\r"
Used options
-I
excludes binary files from the match-l
shows only the file names with matches, rather than all matchesAlso, 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With