Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a git (gitosis) repo where every developer have a main branch. I have a script in post-update hook that rebuild main web site and test websites for every developer on every PUSH.

I want to rebuild only site corresponding to the committed branch, but don't know how to determine committed branch name. Could anyone help?

share|improve this question
up vote 2 down vote accepted

Each argument to the post-update is the name of a ref which was updated by the push, and a branch is a ref whose name looks like refs/heads/<branch> so a script to do what you want would look something like this:


for ref in "$@"
  case "$ref" in
    refs/heads/*) /path/to/rebuild-site `basename $ref`;;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.