Skip to content

Instantly share code, notes, and snippets.

@jtdp
Last active January 24, 2024 08:59
Show Gist options
  • Star 72 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save jtdp/5443498 to your computer and use it in GitHub Desktop.
Save jtdp/5443498 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
@cipri-tom
Copy link

@martynov-dm you should run git permission-resetb not git apply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment