如何使用SSH详细模式运行git push / pull命令?

时间:2014-08-19 16:28:33

标签: git ssh

如果我跑" git push"使用GIT_TRACE = 2环境变量,我得到以下内容:

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' 'git@bitbucket.org' 'git-receive-pack '\''kevinburke/letter.git'\'''

除非有时出现此错误,否则哪个很好:

fatal: Could not read from remote repository.

我只是间歇性地得到它所以我不确定发生了什么。我知道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.

如果我可以git运行带有-vvv的ssh命令,那就太棒了。有没有办法用环境变量或配置设置启用它?

2 个答案:

答案 0 :(得分:51)

从Git版本2.3.0开始,您可以使用环境变量GIT_SSH_COMMAND并传递-v详细参数,如下所示:

GIT_SSH_COMMAND="ssh -v" git clone example

从Git版本2.10.0开始,您甚至可以按每个仓库或全局配置:

git config core.sshCommand "ssh -v"
git pull
git push

答案 1 :(得分:36)

将它放在〜/ .ssh / config文件中:

Host <git-server-FQDN> LogLevel (QUIET|FATAL|ERROR|INFO|VERBOSE|DEBUG|DEBUG1|DEBUG2|DEBUG3)

与服务器交互的后续git命令应该产生所需的调试输出。

相关问题