gpt4 book ai didi

git - 在 Git for Windows 中使用 GIT_SSH_COMMAND

转载 作者:太空狗 更新时间:2023-10-29 12:51:18 28 4
gpt4 key购买 nike

我现在正在使用 Git for Windows 2.x 的第四版候选版本,并在 shell 中使用 GIT_SSH_COMMAND 来避免 SSH 的主机验证。在 Git Bash 中,我写了这样的东西:

$ GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git push origin master

我怎样才能在 Windows cmd 中做这样的事情?在任何地方都找不到任何答案。

最佳答案

您不必再在 Windows 中设置环境变量。

使用 git 2.10+(2016 年第 3 季度),您还可以为 GIT_SSH_COMMAND 设置一个config,这比环境变量更容易(并且可以设置全局,或本地特定 repo )

参见 commit 3c8ede3 (2016 年 6 月 26 日)作者:Nguyễn Thái Ngọc Duy (pclouds) .
(由 Junio C Hamano -- gitster -- merge 于 commit dc21164 ,2016 年 7 月 19 日)

A new configuration variable core.sshCommand has been added to specify what value for GIT_SSH_COMMAND to use per repository.

core.sshCommand:

If this variable is set, git fetch and git push will use the specified command instead of ssh when they need to connect to a remote system.
The command is in the same form as the GIT_SSH_COMMAND environment variable and is overridden when the environment variable is set.

这意味着 git push 可以是:

cd /path/to/my/repo
git config core.sshCommand 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
# later on
git push origin master

在 Git 2.16(2018 年第一季度)中,您将拥有一种新机制来就地升级有线协议(protocol),该机制已被提出并证明它可以与旧版本的 Git 一起工作而不会损害它们。

参见 commit 6464679 (2017 年 10 月 16 日),和 commit 0cd8328 (2017 年 9 月 26 日)Jonathan Tan (jhowtan) .
参见 commit 94b8ae5 , commit 3c88ebd , commit 19113a2 , commit 0c2f0d2 , commit 2609043 , commit aa9bab2 , commit dfe422d , commit 373d70e , commit 5d2124b (2017 年 10 月 16 日)Brandon Williams (mbrandonw) .
(由 Junio C Hamano -- gitster -- merge 于 commit 4c6dad0 ,2017 年 12 月 6 日)

ssh: introduce a 'simple' ssh variant

When using the 'ssh' transport, the '-o' option is used to specify an environment variable which should be set on the remote end.
This allows Git to send additional information when contacting the server, requesting the use of a different protocol version via the 'GIT_PROTOCOL' environment variable like so: "-o SendEnv=GIT_PROTOCOL".

Unfortunately not all ssh variants support the sending of environment variables to the remote end.
To account for this, only use the '-o' option for ssh variants which are OpenSSH compliant.
This is done by checking that the basename of the ssh command is 'ssh' or the ssh variant is overridden to be 'ssh' (via the ssh.variant config).

Other options like '-p' and '-P', which are used to specify a specific port to use, or '-4' and '-6', which are used to indicate that IPV4 or IPV6 addresses should be used, may also not be supported by all ssh variants.

Currently if an ssh command's basename wasn't 'plink' or 'tortoiseplink', Git assumes that the command is an OpenSSH variant.
Since user configured ssh commands may not be OpenSSH compliant, tighten this constraint and assume a variant of 'simple' if the basename of the command doesn't match the variants known to Git.
The new ssh variant 'simple' will only have the host and command to execute ([username@]host command) passed as parameters to the ssh command.

关于git - 在 Git for Windows 中使用 GIT_SSH_COMMAND,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31475646/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com