我有一个版本为2.1.2
的git
代码库,其中包含一个ssh
的远程仓库:
$ git remote -v
origin ssh://dettorer@dettorer.net:/home/dettorer/my_project (fetch)
origin ssh://dettorer@dettorer.net:/home/dettorer/my_project (push)
哪些推送失败:
$ git push
Bad port ''
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
除非我使用
--verbose
开关:$ git push --verbose
Pushing to ssh://dettorer@dettorer.net:/home/dettorer/my_project
Enter passphrase for key '/home/dettorer/.ssh/id_rsa':
Counting objects: 7, done.
...
To ssh://dettorer@dettorer.net:/home/dettorer/my_project
e633fe9..5d2e9de master -> master
updating local tracking ref 'refs/remotes/origin/master'
我按照这个答案的提示,增加了 ssh
的日志级别,但是在没有使用 --verbose
的情况下,git push
的输出仍然完全相同。
它可能来自哪里呢?
正如 nwinkler 建议的那样,以下是两个带有 GIT_TRACE=2
的命令的输出:
$ GIT_TRACE=2 git push
13:42:33.002392 git.c:349 trace: built-in: git 'push'
13:42:33.033594 run-command.c:341 trace: run_command: 'ssh' '-p' '' 'dettorer@dettorer.net' 'git-receive-pack '\''/home/dettorer/my_project'\'''
Bad port ''
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
$ GIT_TRACE=2 git push -v
13:42:39.929236 git.c:349 trace: built-in: git 'push' '-v'
Pushing to ssh://dettorer@dettorer.net:/home/dettorer/my_project
13:42:39.944837 run-command.c:341 trace: run_command: 'ssh' 'dettorer@dettorer.net' 'git-receive-pack '\''/home/dettorer/my_project'\'''
Enter passphrase for key '/home/dettorer/.ssh/id_rsa':
除非我使用
--verbose
,否则确实有一个带有空参数的额外'-p'
选项。编辑:这变得更加晦涩了:
$ git push origin
Bad port ''
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
$ git remote add test test
$ git push origin
Enter passphrase for key '/home/dettorer/.ssh/id_rsa':
$ git remote remove test
$ git push origin
Bad port ''
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
.ssh/config
文件里有什么内容吗?如果你运行ssh -vvv dettorer@dettorer.net
会发生什么? - nwinkler.ssh/config
里什么也没有(除了我增加ssh的日志级别时)。当使用ssh -vvv
时没有任何问题(即使没有-vvv
,我也可以正确地进行ssh)。 - DettorerGIT_TRACE=2 git push
的输出是什么?它应该打印出正在运行的确切ssh
命令。 - nwinkler