Skip to content

Instantly share code, notes, and snippets.

@virtualstaticvoid
Created September 12, 2014 15:12
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 virtualstaticvoid/f3ef72c052a8156d0929 to your computer and use it in GitHub Desktop.
Save virtualstaticvoid/f3ef72c052a8156d0929 to your computer and use it in GitHub Desktop.
Git script for resetting the file modes
#!/bin/bash
# make sure we're at the root of git repo
if [ ! -d .git ]; then
echo "Error: must run this script from the root of a git repository"
exit 1
fi
git diff --numstat \
| awk '{if (($1 == "-" && $2 == "-") || ($1 == "0" && $2 == "0")) { $1=$2=""; print }}' \
| sed 's/[^\ ].*/"&"/' \
| xargs git checkout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment