将 SSH 选项传递给 git-clone

hkn*_*nik 7 ssh git command-switch

我使用 SSH 连接到我的服务器:

ssh user@server -p 2224 -zZ abcd

我的服务器上也有一个 git 存储库。我知道克隆的唯一方法是:

git clone ssh://user@server.com:2224/path/to/repo

使用上述命令我无法连接到我的服务器,因为-zZ abcd不在命令中。我尝试了以下命令但不起作用。

git clone ssh://user@server.com:2224/path/to/repo -zZ abcd

git clone "ssh://user@server.com:2224/path/to/repo -zZ abcd"

如何在git-clone命令中包含 ssh 参数?

Laz*_*ger 5

您可以设置配置选项以节省输入;所以,经过

$ cat >>.git/config <<EOF
[remote "myrepo"]
    url = ssh://user@server.com:2224/path/to/repo -zZ abcd
EOF
Run Code Online (Sandbox Code Playgroud)

只用 git clone myrepo

有关详细信息,请参阅git config 中remote..url 选项的说明。