Git unstage lines where the only changes is white-space?

I have a source code file that for some reason have ended up with mixed indentation (spaces and tabs used for indentation).

I have made quite a few changes and now I wish to commit those changes in git. Unfortunately I by accident instructed my editor to fix all indentation. So now it looks like I have modified a lot of lines, where the only change is changes to white-space.

  • Git config alias doesn't work anymore
  • Git denies the existence of remote branches
  • How to git checkout a remote branch named the same as a directory?
  • Git Checkout Particular Branch
  • openshift post_deploy action hook does not working
  • Cannot choose port on cloning git via ssh from aptana studio 3
  • My commit has to be reviewed by my colleagues in Gerrit, so having a lot of white-space-only changed lines show up as changes adds a lot of noise.

    How can I unstage all lines in a file, where the only change is to white-space (or indentation), such that my git commit only contains actually changed lines?

    (Or alternatively, how can I only stage the lines of a file where more than white-space is changed?)

  • How to login Gerrit as Administrator
  • How can I continue merging after a double-modify?
  • Git problems - how to set up a NAS with a repo for a website
  • Gitosis post-update wont run
  • In git, how do I view a previous version of an image file?
  • Are there any high profile commercial users of GIT?
  • One Solution collect form web for “Git unstage lines where the only changes is white-space?”

     git diff -w --no-color [file names] | git apply --cached --ignore-whitespace

    Basically it applies the patch which would be applied with add without whitespace changes. You will notice that after that there will still be unstaged changes, it’s the whitespaces left, to checkout them run: git checkout .

    Git Baby is a git and github fan, let's start git clone.