Skip to content

Instantly share code, notes, and snippets.

@ABGEO
Last active June 29, 2021 07:09
Show Gist options
  • Save ABGEO/bff12e6ec8cc14773814e13e943a7166 to your computer and use it in GitHub Desktop.
Save ABGEO/bff12e6ec8cc14773814e13e943a7166 to your computer and use it in GitHub Desktop.
Reset the original permissions in local Git repository.
#!/bin/bash
# Version 1
## 1) Create a reverse patch
## 2) Include only the permission changes
## 3) Apply the patch to our working copy
git diff -p -R --no-ext-diff --no-color | grep -E "^(diff|(old|new) mode)" --color=never | git apply
# Version 2:
## Add as git command
git config --global --add alias.reset-permissions '!git diff -p -R --no-ext-diff --no-color | grep -E "^(diff|(old|new) mode)" --color=never | git apply'
## Call: git reset-permissions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment