mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: daicoden <>
Subject: Git Hooks
Date: Wed, 16 Sep 2009 16:24:11 -0700 (PDT)	[thread overview]
Message-ID: <> (raw)


I have a git repo host at /home/git/blog.git.  I have a copy checked out at
/var/www/blog.  I have a script as follows:

cd /var/www/blog
thin -s 2 -C config.yml -R stop
git pull origin master
thin -s 2 -C config.yml -R start 

>From a local machine I can commit to the repo, push, and then run this
script and the server will update just fine.  I wanted to make this
automatic so I wrote the following post-receive hook.

if git log -n1 | grep -q "#publish" || git log -n1 | grep -q "#Publish"

If #publish is in the commit message then it runs the first script.  I found
through trial and error that when you use the command git from within a git
hook it needs to be executed in a .git directory, so I changed the first
script to.

cd /var/www/blog
thin -s 2 -C config.yml -R stop
cd .git
git pull origin master
cd ..
thin -s 2 -C config.yml -R start 

Everything executes, I see the messages of the server stopping, the new info
being pulled, then the server starts again, but the server does not reflect
any changes.  If I then manually stop the server, use git reset --hard, and
then start the server again it works fine.

My only thought is that the cause of this has something to do with git
operating differently when you call it from within a hook.  Unfortunately, I
don't have any thoughts on how to fix it.
View this message in context:
Sent from the git mailing list archive at

             reply	other threads:[~2009-09-16 23:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-16 23:24 daicoden [this message]
2009-09-16 23:31 ` Git Hooks Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2017-12-15 19:12 Satyakiran Duggina
2017-12-15 19:23 ` Bryan Turner
2017-12-15 20:48   ` Satyakiran Duggina
2017-12-16  9:53     ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).