I try to get the name of files which have changes are more than whitespaces. (In another word, I don't want the files with only whitespaces changes be listed.)
I tried "git diff --name-only -w" it doesn't work. It lists all the changed files including the whitespaces only ones.
To solve this issue, I wrote a script to do it. Hope it useful to others.
#!/usr/bin/env bash
GIT_REPO_ROOT=`git rev-parse --show-toplevel`
# cd ${GIT_REPO_ROOT}
for f in `git diff --name-only`;
do
MY_DIFF=`git diff -w ${GIT_REPO_ROOT}/${f}`
if [[ ! ${MY_DIFF} == "" ]];
then
echo ${GIT_REPO_ROOT}/${f}
fi
done
This script reduce the result from 88 files ('git diff --name-only') to 8 files.
Add ignore-blank-lines option. Try
git diff --name-only -w --ignore-blank-lines
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