Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
git add files ignoring whitespace
# props: https://stackoverflow.com/questions/3515597/add-only-non-whitespace-changes#answer-7149602
git diff -U0 -w --no-color | git apply --cached --ignore-whitespace --unidiff-zero
@mmrko

This comment has been minimized.

Copy link
Owner Author

@mmrko mmrko commented Sep 15, 2017

To add an alias (e.g. ganw) for it in your ~/.bashrc (or alike):

# ~/.bashrc
alias ganw="git diff -U0 -w --no-color | git apply --cached --ignore-whitespace --unidiff-zero"

source ~/.bashrc or open a new terminal tab to make it available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment