reox
reox

Reputation: 5217

Trigger post-receive hook without pushing any refs

Is there any way to trigger the post-receive hook of a git repository without pushing anything?

I'm aware that I can just push an empty commit, which will cause the hook to trigger:

git commit --allow-empty -m "push me" && git push

Upvotes: 1

Views: 335

Answers (2)

Joost
Joost

Reputation: 4134

You can do it as follows, assuming you have access to the server:

echo `git log -2 --format=oneline --reverse | cut -f 1 -d ' ' | xargs` master | ./hooks/post-receive

Upvotes: 2

torek
torek

Reputation: 488013

I don't think there is. If you have control of the server, you can log in there and run the post-receive hook manually, but this runs in a different environment from an actual receive operation. You can simulate the environment more closely by making sure the current directory is in the repository and that $GIT_DIR is set to ..

(When I ran some central-server side git repos in a previous job, I just had some special test repositories I would push to, to run my hooks in "really receiving data" mode for final testing.)

Upvotes: 0

Related Questions