Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git run server side hook when there are no updates

Tags:

git

I have a server side hook (post-update) that will run after every code push I do. Is there any way (or maybe another hook?) to run it even if there are no new changes to push?

Example:

$ git push origin master
remote: Hook running....
$
$ git push origin master
Everything up-to-date
$

I'd like it to be run again. Is that possible?

like image 475
Matt Avatar asked Mar 05 '26 18:03

Matt


1 Answers

Create a pre-receive hook, make it exit 1, and from the client git push origin master HEAD:non-existing-branch. This will trigger the pre-receive hook, even if there are no changes to master.

To avoid error messages, make the pre-receive hook exit successfully (exit 0), and manually remove the the non-existing-branch from the post-receive hook. However, this creates a small time window (when the file non-existing-branch exists) with the git push ... initiated from another client won't run the hooks.

like image 186
pts Avatar answered Mar 07 '26 07:03

pts



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!