Skip to content

Instantly share code, notes, and snippets.

@dadbob
Forked from jtdp/gist:5443498
Created November 18, 2019 19:38
Show Gist options
  • Save dadbob/2e823b5fd67a3cdec50f5d4a50a839c9 to your computer and use it in GitHub Desktop.
Save dadbob/2e823b5fd67a3cdec50f5d4a50a839c9 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