The style of my project does say to trim trailing whitespace, but this makes diffs very, very messy. I like to consolidate them to one commit before I commit the actual fix.
This is closely related to Add only non-whitespace changes, but it is asking the exact opposite:
Is there a way to add only the whitespace changes to the staging area?
We use the git diff -w command to ignore all whitespace differences. It will ignore spaces at the beginning, middle, and end of lines.
Right click on base branch in the Git tab, and do reset. It will undo the commit and stage non-whitespaces changes for commit. Now commit and push -f (I always force push via command line). That's it, you are done!
The git add command adds new or changed files in your working directory to the Git staging area. git add is an important command - without it, no git commit would ever do anything. Sometimes, git add can have a reputation for being an unnecessary step in development.
in 1.6. 3.2, " whitespace " attribute that is set was meant to detect all errors known to git, but it told git to ignore trailing carriage-returns.
You can try the following "trick":
git add -A git diff --cached -w | git apply --cached -R
This basically adds everything to the index, then unstages all changes which affect more than whitespace.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With