我正在用 python 编写一个 git pre-receive 钩子(Hook),并希望在推送选项中接收从命令行传递的参数。
git push -push-option='my option'
如何访问我的预接收 Hook 内的推送选项?
最佳答案
The number of push options given on the command line of
git push --push-option=...
can be read from the environment variableGIT_PUSH_OPTION_COUNT
, and the options themselves are found inGIT_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
.
关于python - 预接收 Hook 中的 git push 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48463761/