I often push code with some tab instead of spaces or vice versa, or insert a line break to improve code readability. How do I tell git not to look for those changes?
For diff and blame, you can ignore all whitespace changes with -w : git diff -w , git blame -w . For git apply and git rebase , the documentation mentions --ignore-whitespace . For merge, it looks like you need to use an external merge tool.
By default, core. autocrlf is set to false on a fresh install of Git, meaning Git won't perform any line ending normalization. Instead, Git will defer to the core. eol setting to decide what line endings should be used; core.
If a directory matches an ignore pattern, then it is shown, but not paths contained in the ignored directory. If a directory does not match an ignore pattern, but all contents are ignored, then the directory is not shown, but all contents are shown.
" git status --branch --porcelain " displays the status of the branch (ahead, behind, gone), and used gettext to translate the string. Use hardcoded strings when --porcelain is used, but keep the gettext translation for " git status --short " which is essentially the same, but meant to be read by a human.
I could not find a native git solution for identifying what really changed using git status
but the following one-liner works well under linux:
for m in $(git status | grep modified| awk '{print $2}');do test -z "$(git diff -w $m)" || echo $m;done
The result will be a list of modified files excluding files with only whitespace changes.
This is especially useful before writing commit messages when you want to see only the files with real edits which is often a problem when moving back and forth between windows and linux systems. If you have control of both systems then configuring whitespace settings in git may be a cleaner solution.
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