Developers Notes

My Journey as Software Architect

Git trailing whitespace error on commit

sometimes, when you pull package from repo , or Pod, you will have error something rant about whitespace

trailing whitespace

after looking on some SO, i figured the easy way to fix this.

git diff --cached --no-color > stage.diff && git apply --index -R stage.diff && git apply --index --whitespace=fix stage.diff && rm -f stage.diff

 

finally, i can commit my changes to repo

 

references:

How to not leave trailing whitespace (using your editor or Git) - makandra dev
https://makandracards.com/makandra/11541-how-to-not-leave-trailing-whitespace-using-your-editor-or-git