Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git push option in pre receive hook

Tags:

git

python

gitlab

I am writing a git pre-receive hook in python and would like to receive the arguments passed from the command line in the push-option.

git push -push-option='my option'

How do I access the push option inside of my pre-receive hook?

like image 547
user9224574 Avatar asked Oct 23 '25 04:10

user9224574


1 Answers

See the githook documentation.

The number of push options given on the command line of git push --push-option=... can be read from the environment variable GIT_PUSH_OPTION_COUNT, and the options themselves are found in GIT_PUSH_OPTION_0, GIT_PUSH_OPTION_1,…​ If it is negotiated to not use the push options phase, the environment variables will not be set. If the client selects to use push options, but doesn’t transmit any, the count variable will be set to zero, GIT_PUSH_OPTION_COUNT=0.

like image 85
Ben Harris Avatar answered Oct 25 '25 17:10

Ben Harris



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!