Skip to content

Instantly share code, notes, and snippets.

@jontsai
Forked from jtdp/gist:5443498
Created January 19, 2022 09:53
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 jontsai/0ef7f37f75053d1e4e4a43e795975653 to your computer and use it in GitHub Desktop.
Save jontsai/0ef7f37f75053d1e4e4a43e795975653 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