How to discard only mode changes with Git
I found this snippet that does exactly what I want.
git diff -p \
| grep -E '^(diff|old mode|new mode)' \
| sed -e 's/^old/NEW/;s/^new/old/;s/^NEW/new/' \
| git apply
I assigned this snippet to a git alias then I can type git fix-perm
in directories where permissions are messed up.
git config --global alias.fix-perm "!f(){ git diff -p | grep -E '^(diff|old mode|new mode)' | sed -e 's/^old/NEW/;s/^new/old/;s/^NEW/new/' | git apply; }; f"
Credits to jtdp. (https://gist.github.com/jtdp/5443498)