为 git Remote 提供 SSH 参数?

为 git Remote 提供 SSH 参数?

由于某种原因,如果我尝试运行任何ssh命令,我的控制台就会挂起。例如:

ssh user@server date会挂起,

ssh -f user@server date作品。

如果我想在 URL-f中包含参数git remote,我该怎么做?现在我有:

git remote add origin ssh://user@server/home/user/repo/mine.git但如果我尝试推/拉它,它就会挂起。我想将-f参数添加到此 URL,因为我怀疑它会解决问题。

如何告诉在调用时git使用参数?-fssh

答案1

从精美的手册中git(1)我们发现

   GIT_SSH, GIT_SSH_COMMAND
       If either of these environment variables is set then git fetch and
       git push will use the specified command instead of ssh when they
       need to connect to a remote system. The command will be given
       exactly two or four arguments: the username@host (or just host)
       from the URL and the shell command to execute on that remote
       system, optionally preceded by -p (literally) and the port from the
       URL when it specifies something other than the default SSH port.

       $GIT_SSH_COMMAND takes precedence over $GIT_SSH, and is interpreted
       by the shell, which allows additional arguments to be included.
       $GIT_SSH on the other hand must be just the path to a program
       (which can be a wrapper shell script, if additional arguments are
       needed).

因此,最简单的 via shell 解释是

GIT_SSH_COMMAND="ssh -f" git push ...

或通过 的完整包装GIT_SSH

相关内容