Skip to content

Instantly share code, notes, and snippets.

@allanzi
Forked from jtdp/gist:5443498
Created May 16, 2019 20:16
Show Gist options
  • Save allanzi/1a41f974ffb42cd23725e0b91839fd83 to your computer and use it in GitHub Desktop.
Save allanzi/1a41f974ffb42cd23725e0b91839fd83 to your computer and use it in GitHub Desktop.
Revert file permission changes in local git repository.. Very useful when you change permissions due to working on a samba share. Lifted from: http://stackoverflow.com/questions/2517339/git-how-to-recover-the-file-permissions-git-thinks-the-file-should-be
git diff -p \
| grep -E '^(diff|old mode|new mode)' \
| sed -e 's/^old/NEW/;s/^new/old/;s/^NEW/new/' \
| git apply
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment