Hi David,

> When you say "reset GIT_DIR ." what are the exact commands
> you're using?  I'm not sure what that means.

Sorry, it was "unset GIT_DIR"

> If you have uncommitted changes in tux4kids-web then that will
> fail because 'git pull' might complain about losing your
> uncommitted changes.
> If the intention is to never do that (unless by accident) then
> the following works by throwing away any accidental edits in
> /home/groups/tux4kids/tux4kids-web:
> #!/bin/sh
> unset GIT_DIR
> cd /home/groups/tux4kids/tux4kids-web &&
> git fetch origin &&
> git reset --hard origin/master

That's essentially what I did - to be exact, my hooks/post-update was
# Create marker file to prove that this script ran (just for initial testing):
touch hook_ran

# Propagate update to htdocs for web site
cd /home/groups/tux4kids/tux4kids-web &&

and the update-sh script in the above location was
unset GIT_DIR
git fetch origin
git reset --hard origin/master

If I ran "./post-update" directly, the script seemed to behave as
intended, with creation of the "hook_ran" file as a simple indicator
that script was executed.

> If you 'git push' and everything's up-to-date then it probably
> won't run, I would assume.

I know, so I made another clone on the server machine and made small
changes (either adding or deleting a file called "test"), followed by
a push.  The push never caused the hook to run (i.e. the hook
directory never created the "hook_ran" file), although the push itself
seemed to take place, and if I pulled manually from
/home/groups/tux4kids/tux4kids-web, the "test" file appeared or
disappeared appropriately.  Could the fact that the "test" file was
empty explain this?

Anyway, I found a slightly different approach in a blog post
(http://toroid.org/ams/git-website-howto) which involved making the
"main" tux4kids-web.git repo non-bare with the specified worktree path
in the location for the websites htdocs:

$ mkdir /home/groups/tux4kids/tux4kids-web
$ git config core.worktree  /home/groups/tux4kids/tux4kids-web
$ git config core.bare false
$ git config receive.denycurrentbranch ignore

And then putting a "git checkout -f" in the post-receive hook:

$ cat > hooks/post-receive
git checkout -f
$ chmod +x hooks/post-receive

and that worked.

Thanks for your advice and information.  (I'm still puzzled why I
never saw any evidence that the post-update hook was executed after a

David Bruce

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-us...@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to