-
-
Save davidglezz/383afabfe3c87dd9c7ae686d2b3d371b to your computer and use it in GitHub Desktop.
Git hook (post-receive): update working tree on PUSH
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 is placed in Bare repository and it updates Working tree whenever a PUSH | |
# is executed | |
# | |
# Assuming following file structure: | |
# . | |
# |-- myproject | |
# |-- myproject.git | |
# set WORKTREE=../myproject | |
# | |
# Where myproject.git - current bare repo and myproject - working directory | |
# To enable this hook, rename this file to "post-receive" and make sure it is executable | |
# | |
WORKTREE=../myproject | |
GITDIR=$WORKTREE.git | |
cd $WORKTREE | |
# update the working tree | |
git --work-tree=./ --git-dir=$GITDIR checkout -f | |
git --work-tree=./ --git-dir=$GITDIR clean -fd | |
# return to git directory | |
cd $GITDIR | |
# we have to read stdin in order to avoid | |
# sideband demutiplexer error | |
# more details here: http://bit.ly/PzbRwo | |
while read oldrev newrev refname | |
do | |
: | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment