Flame
Flame

Reputation: 2207

Git Hook: Take action when a branch is advanced

I'm looking to build and publish a latex document every time I advance the tip of a specific branch.

I'm looking at what hook I should be putting my build script and which conditions I need to check for.

Upvotes: 6

Views: 3483

Answers (2)

msmart
msmart

Reputation: 306

Probably a little late... but you can find out which branch was committed to by using

if [ `git rev-parse --abbrev-ref HEAD` = "master" ]; then
  ...
fi

in you script when you checked out the branch to commit in it.

Upvotes: 14

Pat Notz
Pat Notz

Reputation: 214516

If changes are coming in via a push to a remote, then on the remote server you'll want to use the post-receive hook (though if you use pre-receive then you can reject the push if, say, latex fails).

If you're using your local repository you should use post-commit (or pre-commit if you want to be able to reject the commit).

The hooks are documented in the git hooks man page.

Upvotes: 4

Related Questions