Git tool to remove lines from staging if they consist only of changes in whitespace
Posted
by Max Howell
on Stack Overflow
See other posts from Stack Overflow
or by Max Howell
Published on 2009-11-17T20:39:50Z
Indexed on
2010/03/29
4:23 UTC
Read the original article
Hit count: 301
The point in removing trailing whitespace is that if everyone does it always then you end up with a diff that is minimal, ie. it consists only of code changes and not whitespace changes.
However when working with other people who do not practice this, removing all trailing whitespace with your editor or a pre-commit hook results in an even worse diff. You are doing the opposite of your intention.
So I am asking here if there is a tool that I can run manually before I commit that unstages lines from staging that are only changes in whitespace.
Also a bonus would be to change the staged line to have trailing whitespace removed for lines that have code changes.
Also a bonus would be to not do this to Markdown files (as trailing space has meaning in Markdown).
I am asking here as I fully intend to write this tool if it doesn't already exist.
© Stack Overflow or respective owner