Reset file permissions

From time to time (for instance when using docker) your file permissions might be changed, but you don’t want to commit those changes to your repository.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: test.md

no changes added to commit (use "git add" and/or "git commit -a")

$ git diff
diff --git a/test.md b/test.md
old mode 100644
new mode 100755

$ git diff -p -R | grep -E "^(diff|(old|new) mode)" | git apply
$ git status
On branch master
nothing to commit, working directory clean