-
Notifications
You must be signed in to change notification settings - Fork 23
Ignore whitespaces on commit
There is no simple solution provided by _git_ for that problem.
But _github_ provides smart feature to ignore whitespaces in diff mode simple by adding w=1 parameter to url (**?w=1**).
[github-secrets](https://github.com/blog/967-github-secrets)
Nevertheless, one can use tricky thing to omit whitespaces in commit using applying patch from from diff that omit whitespaces: * `git diff -w|--ignore-all-space` -> Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none. * `git diff -b|--ignore-space-change` -> Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent. * `git diff --ignore-space-at-eol` --> Ignore changes in whitespace at EOL.
Then use:
* `git apply --cached --ignore-whitespaces patch`
**important:** `--cached` -> Apply a patch without touching the working tree. Instead take the cached data, apply the patch, and store the result in the index without using the working tree.
References: