I know there are a ton of questions/answers similar to this one, however I could not find a specific answer to this problem. We are a .net shop and are using git.
I would like a way to ignore CRLF (^M) changes to files when doing a git status. While developing, other processes are occasionally modify files and injecting the CRLF, ultimately resulting in them showing as modified when a git status is done. I have the line "* text=auto" within my .gitattributes file in order to normalize line endings at checkout/commit but this is not what I am looking for. I have also tried to add the following to the git config (core.whitespace=cr-at-eol) but they still show as modified.
How do I tell git to ignore all changes to CRLF (^M)?
If you want to see the core. autocrlf setting for a particular repository, run git config core. autocrlf inside it. You'll get back the value it's set to, or nothing if it is unset.
text eol=crlf Git will always convert line endings to CRLF on checkout. You should use this for files that must keep CRLF endings, even on OSX or Linux. text eol=lf Git will always convert line endings to LF on checkout. You should use this for files that must keep LF endings, even on Windows.
The easiest way to delete a file in your Git repository is to execute the “git rm” command and to specify the file to be deleted. Note that by using the “git rm” command, the file will also be deleted from the filesystem.
The git status command displays the state of the working directory and the staging area. It lets you see which changes have been staged, which haven't, and which files aren't being tracked by Git. Status output does not show you any information regarding the committed project history.
You cannot ignore types of filechanges for git status
. You can use .gitignore to ignore entire files. And you can use the various whitespace options to transform what is committed, what is highlighted (in red) or shown at all in the diff and commit views.
The reasons you cannot ignore these filechanges are:
In short, you probably need to fix your other processes or develop clean-up post-processes. Alternatively you could use:
git diff-files --name-status --ignore-space-at-eol
This is not a perfect analogue of status proper, but it might be enough for your needs. For convenience, you can even build a git-alias
'd "statusx" command by adding to your .gitconfig:
[alias]
statusx = diff-files --name-status --ignore-space-at-eol
There are some additional whitespace options if that proves inadequate: --ignore-space-change
and --ignore-all-space
. See git diff --help
for more detail.
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