如何在 SSH 详细模式下运行 git push/pull 命令?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25388499/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I run git push/pull commands with SSH verbose mode?
提问by Kevin Burke
If I run "git push" with the GIT_TRACE=2 environment variable, I get the following:
如果我使用 GIT_TRACE=2 环境变量运行“git push”,我会得到以下信息:
09:25:28.098743 git.c:349 trace: built-in: git 'push' 'origin' 'master'
09:25:28.100261 run-command.c:341 trace: run_command: 'ssh' '[email protected]' 'git-receive-pack '\''kevinburke/letter.git'\'''
Which is great except sometimes I get this error:
这很好,但有时我会收到此错误:
fatal: Could not read from remote repository.
I only get it intermittently so I'm not sure what's going on. I know ssh has a verbose mode:
我只是间歇性地得到它,所以我不确定发生了什么。我知道 ssh 有一个详细模式:
-v Verbose mode. Causes ssh to print debugging messages about its progress.
This is helpful in debugging connection, authentication, and configuration
problems. Multiple -v options increase the verbosity. The maximum is 3.
It would be great if I could get git
to run that ssh command with -vvv
turned on. Is there a way to enable this with environment variables or with config settings?
如果我可以git
在-vvv
打开的情况下运行该 ssh 命令,那就太好了。有没有办法用环境变量或配置设置启用它?
采纳答案by goddardcm
Put this in your ~/.ssh/config file:
把它放在你的 ~/.ssh/config 文件中:
Host <git-server-FQDN> LogLevel (QUIET|FATAL|ERROR|INFO|VERBOSE|DEBUG|DEBUG1|DEBUG2|DEBUG3)
Subsequent git commands that interact with the server should produce desired debug output.
与服务器交互的后续 git 命令应该产生所需的调试输出。
回答by Flimm
From Git version 2.3.0, you can use the environment variable GIT_SSH_COMMAND
and pass the -v
verbose argument like this:
从 Git 版本 2.3.0 开始,您可以使用环境变量GIT_SSH_COMMAND
并-v
像这样传递详细参数:
GIT_SSH_COMMAND="ssh -v" git clone <REPO_SSH>
you can also pass -vvv
for even more verbose level:
您还可以通过-vvv
更详细的级别:
GIT_SSH_COMMAND="ssh -vvv" git clone <REPO_SSH>
(as seen here https://askubuntu.com/a/620985/975188)
(如这里所见https://askubuntu.com/a/620985/975188)
note that you can also run this with other git
commands, such as git push
, git fetch
etc.
请注意,您还可以与其他运行此git
命令,如git push
,git fetch
等。
From Git version 2.10.0, you can even configure this per repo or globally:
从 Git 版本 2.10.0 开始,您甚至可以为每个 repo 或全局配置它:
git config core.sshCommand "ssh -v"
git pull
git push