在 "git push" 中通过“--push-option=”发送多个选项
Sending multiple options via "--push-option=" in "git push"
随着 Git 2.10 出现了一个新选项 [--push-option=]。创建裸存储库时,会在 hooks 目录中自动创建 post-receive.sample,如下所示:
#!/bin/sh
#
# An example hook script to make use of push options.
# The example simply echoes all push options that start with 'echoback='
# and rejects all pushes when the "reject" push option is used.
#
# To enable this hook, rename this file to "pre-receive".
我尝试了以下步骤
- 正在重命名文件以预接收
- 将存储库克隆到本地计算机
- 尝试过
git push --push-option=echoback=Hello_world
正如示例所说,它将 Hello_world
放回我的终端。
Git Hook Manual 说我可以通过 --push-option=
发送多个选项,正如手册所建议的那样,这些选项将通过 GIT_PUSH_OPTION_0, GIT_PUSH_OPTION_1,...
提供。
我的问题是我应该如何传递多个选项?可以通过 --push-option=
传递
尝试过的选项:
git push --push-option="echoback=Hello echoback=World"
git push --push-option="echoback=Hello;echoback=World"
git push --push-option="echoback=Hello&echoback=World"
git push --push-option="echoback=Hello%echoback=World"
git push --push-option="echoback=Hello,echoback=World"
尝试以下操作:
git push --push-option="echoback=Hello" --push-option="echoback=World"
这将分隔 --push-option
s
Git 2.15.x/2.16(2018 年第一季度)阐明了多个推送选项的用法,现在将“--push-option=<string>
”选项添加到“git push
”默认为通过 push.pushOption
变量配置的字符串列表。
因此您可以使用多个推送选项:
git push --push-option="a" --push-option="b"
或者使用多个配置字符串
~/.gitconfig
push.pushoption = a
push.pushoption = b
参见 commit d805275 (23 Oct 2017) by Marius Paliga (``)。
(由 Junio C Hamano -- gitster
-- in commit c692fe2 合并,2017 年 11 月 6 日)
builtin/push.c
: add push.pushOption
config
Push options need to be given explicitly, via the command line as "git push --push-option <option>
".
Add the config option push.pushOption
, which is a multi-valued option, containing push options that are sent by default.
When push options are set in the lower-priority configulation file
(e.g. /etc/gitconfig
, or $HOME/.gitconfig
), they can be unset later in
the more specific repository config by the empty string.
随着 Git 2.10 出现了一个新选项 [--push-option=]。创建裸存储库时,会在 hooks 目录中自动创建 post-receive.sample,如下所示:
#!/bin/sh
#
# An example hook script to make use of push options.
# The example simply echoes all push options that start with 'echoback='
# and rejects all pushes when the "reject" push option is used.
#
# To enable this hook, rename this file to "pre-receive".
我尝试了以下步骤
- 正在重命名文件以预接收
- 将存储库克隆到本地计算机
- 尝试过
git push --push-option=echoback=Hello_world
正如示例所说,它将 Hello_world
放回我的终端。
Git Hook Manual 说我可以通过 --push-option=
发送多个选项,正如手册所建议的那样,这些选项将通过 GIT_PUSH_OPTION_0, GIT_PUSH_OPTION_1,...
提供。
我的问题是我应该如何传递多个选项?可以通过 --push-option=
尝试过的选项:
git push --push-option="echoback=Hello echoback=World"
git push --push-option="echoback=Hello;echoback=World"
git push --push-option="echoback=Hello&echoback=World"
git push --push-option="echoback=Hello%echoback=World"
git push --push-option="echoback=Hello,echoback=World"
尝试以下操作:
git push --push-option="echoback=Hello" --push-option="echoback=World"
这将分隔 --push-option
s
Git 2.15.x/2.16(2018 年第一季度)阐明了多个推送选项的用法,现在将“--push-option=<string>
”选项添加到“git push
”默认为通过 push.pushOption
变量配置的字符串列表。
因此您可以使用多个推送选项:
git push --push-option="a" --push-option="b"
或者使用多个配置字符串
~/.gitconfig
push.pushoption = a
push.pushoption = b
参见 commit d805275 (23 Oct 2017) by Marius Paliga (``)。
(由 Junio C Hamano -- gitster
-- in commit c692fe2 合并,2017 年 11 月 6 日)
builtin/push.c
: addpush.pushOption
configPush options need to be given explicitly, via the command line as "
git push --push-option <option>
".
Add the config optionpush.pushOption
, which is a multi-valued option, containing push options that are sent by default.When push options are set in the lower-priority configulation file (e.g.
/etc/gitconfig
, or$HOME/.gitconfig
), they can be unset later in the more specific repository config by the empty string.