Fixing white space issues in GIT

I just found the command for cleaning up my changes before committing them into my GIT repo

for FILE in `git diff --check | sed '/^[+-]/d' | sed -r 's/:[0-9]+:.*//' | uniq`; do sed -i 's/[[:space:]]*$//' "$FILE"; done

This will clean up all trailing spaces and make the spaces which are highlighted red when running git diff go away

Just wanted to note it down somewhere

Leave a Reply

Your email address will not be published. Required fields are marked *