Skip to content

Instantly share code, notes, and snippets.

@halilim
Created March 12, 2013 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halilim/5144287 to your computer and use it in GitHub Desktop.
Save halilim/5144287 to your computer and use it in GitHub Desktop.
Discards files with only newline changes. Main idea from http://stackoverflow.com/questions/12092714/how-to-git-reset-hard-everything-but-4-files NOTE: Test it first without checking out actually!!!
# Windows: doesn't work in Git Bash, use Cygwin (with cd "D:\etc..." first)
for file in $(git diff --ignore-space-at-eol --stat=1000,1000|cut -d' ' -f2|head -n -1); do git add $file; done && git checkout .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment