-
-
Save jnslxndr/2318926 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# | |
# This hook does two three things: | |
# | |
# 1. update the "info" files that allow the list of references to be | |
# queries over dumb transports such as http | |
# | |
# 2. if this repository looks like it is a non-bare repository, and | |
# the checked-out branch is pushed to, then update the working copy. | |
# This makes "push" function somewhat similarly to darcs and bzr. | |
# | |
# 3. if this looks like it is a non-bare repository, and the pushed | |
# branch is not checked-out, check it out. | |
# | |
# To enable this hook, make this file executable by "chmod +x post-update". | |
git-update-server-info | |
is_bare=$(git config --get --bool core.bare) | |
if [ -z "$is_bare" ] | |
then | |
# for compatibility's sake, guess | |
git_dir_full=$(cd $GIT_DIR; pwd) | |
case $git_dir_full in */.git) is_bare=false;; *) is_bare=true;; esac | |
fi | |
if [ "$is_bare" = "false" ] | |
then | |
export GIT_DIR=$(cd $GIT_DIR; pwd) | |
GIT_WORK_TREE=${GIT_WORK_TREE-..} | |
for ref | |
do | |
echo "Updating remote working directory..." | |
git reset --hard | |
git checkout -f $ref | |
echo "Done!" | |
echo "Restarting nginx" | |
/etc/init.d/nginx restart | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment