Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 LaTeX project in git, there is a makefile. So basically a server would have to do this:

git checkout master
make > logfile 2>&1

Given that I push into a repo on the server.

I could do this with a cron job, but it seems kind of missing the point. Is there some way to initiate this after I pushed via SSH?

share|improve this question
I just tried out Hudson/Jenkins. This is a little more powerful, but does what I need. – Martin Ueding Oct 12 '11 at 15:56

You can do this in native git with a post-receive hook. Since you shouldn't be pushing to a non-bare repo, you'll need a script along the lines of this

exec > "$target/$(date +%s)_$(uuidgen).log" 2>&1
mkdir -p "$target"
GIT_WORK_TREE="$target" git checkout -f
cd "$target"

Put that in hooks/post-receive inside the bare repo, and you should be all set (note that this will not create $TARGET_DIR, you'll have to do that manually)

share|improve this answer
That sounds way easier than the whole Jenkins. I'll give it a try in the next days. – Martin Ueding Oct 12 '11 at 18:46
I created the hook, but it is not executed when I push. If I call .git/hooks/post-reveive manually on the server, it works though. – Martin Ueding Oct 13 '11 at 9:08
@queueoverflow: Make sure the permissions are right (i.e. which user is the hook called as?), and the working directory fits. – Paŭlo Ebermann Oct 13 '11 at 14:53

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.