We can do diff with some types of ignoring whitespaces:
1)
git diff --ignore-space-at-eol
# Ignore changes in whitespace at EOL.2)
git diff --ignore-space-change
/git diff -b
# Ignore changes in amount of whitespace.3)
git diff --ignore-all-space
/git diff -w
# Full whitespace ignoringWe can do
git apply --ignore-whitespace
\git apply --ignore-space-change
# Ignore whitesapces when applying patch
But how to exclude files with whitespaces changes from git add *
?
These solutions does not work for me:
1)
git diff -w --no-color | git apply --cached --ignore-whitespace
- It sometimes writes errors and does not add new files to tracking.
2)
git add `git diff -w --ignore-submodules |grep "^[+][+][+]" |cut -c7-`
- It writes errors and do nothing (maybe because I have binary files, not only text files)
P.S.: And maybe there is way to replace files (with whitespaces differences at end or line and whitespaces before EOF differences) with files from last commit?