-
-
Save ottosmops/763922eb500355665f8080e59304f882 to your computer and use it in GitHub Desktop.
Post-update git hook to set right owner and permissions for changed files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # default owner user | |
| OWNER="www-data:www-data" | |
| # changed file permission | |
| PERMISSION="664" | |
| # web repository directory | |
| REPO_DIR="/var/www/sitename" | |
| # remote repository | |
| REMOTE_REPO="origin" | |
| # public branch of the remote repository | |
| REMOTE_REPO_BRANCH="master" | |
| cd $REPO_DIR || exit | |
| unset GIT_DIR | |
| files="$(git diff-tree -r --name-only --no-commit-id HEAD@{1} HEAD)" | |
| git merge FETCH_HEAD | |
| for file in $files | |
| do | |
| sudo chown $OWNER $file | |
| sudo chmod $PERMISSION $file | |
| done | |
| exec git-update-server-info |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment