Resetting Whitespace-Only Changes in Git
I used find -exec
with sed
to do a repository-wide find/replace this morning. Unfortunately, some of the files in the repository didn’t have a newline at the end of the file, but sed
added one. I wanted a one-liner to reset all the whitespace-only changes, and I found it on stackoverflow:
git diff -b --numstat \
| egrep $'^0\t0\t' \
| cut -d$'\t' -f3- \
| xargs git checkout HEAD --
Written by Jon Tai
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Git
Authors
Related Tags
#git
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#