Skip to content

Instantly share code, notes, and snippets.

@yzdann
Forked from jtdp/gist:5443498
Created June 30, 2020 06:55
Show Gist options
  • Save yzdann/e3de21556d10a93a54f897df4b4101f2 to your computer and use it in GitHub Desktop.
Save yzdann/e3de21556d10a93a54f897df4b4101f2 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