[英]git push with ssh remote fails unless verbose
I have a git
(version 2.1.2
) repository with an ssh
remote: 我有一个带有
ssh
远程的git
(版本2.1.2
)存储库:
$ git remote -v
origin ssh://dettorer@dettorer.net:/home/dettorer/my_project (fetch)
origin ssh://dettorer@dettorer.net:/home/dettorer/my_project (push)
Which fails to 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.
Unless… I use the --verbose
switch: 除非......我使用
--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'
I augmented the ssh
log level as hinted in that answer , but the output for git push
(without --verbose
) was the exact same. 我在答案中暗示了
ssh
日志级别的增加,但是git push
(没有--verbose
)的输出完全相同。
Where could it come from? 哪里可以来的?
As nwinkler suggested, here is the output of the two commands with GIT_TRACE=2
: 正如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':
So unless I use --verbose
, there indeed is an extra '-p'
option with an empty argument. 因此,除非我使用
--verbose
,否则确实会有一个带有空参数的额外'-p'
选项。
EDIT: this is getting more obscure: 编辑:这变得越来越模糊:
$ 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.
OK, after seeing your comments, I'm pretty sure I know what's wrong. 好的,看到你的评论后,我很确定我知道什么是错的。
Can you try to change your remote URL to this: 您可以尝试将远程URL更改为:
ssh://dettorer@dettorer.net/home/dettorer/my_project
You've got an extra colon there, which seems to be causing the issue of the additional port. 你在那里有一个额外的冒号,这似乎导致了额外端口的问题。 I don't know why running it with
-v
fixes the problem. 我不知道为什么用
-v
运行它来修复问题。
The git help shows that the following is the supported format for the ssh
protocol: git帮助显示以下是
ssh
协议支持的格式:
ssh://[user@]host.xz[:port]/path/to/repo.git/
As you can see, the colon is only required if you need to set a port. 如您所见,只有在需要设置端口时才需要冒号。 Leave it off if you want to use the standard port.
如果要使用标准端口,请将其关闭。
Note: with Git 2.3.7 (released yesterday, April, 27 2015), this error " Bad port ''
" is no more. 注意:使用Git 2。3。7(昨天,2015年4月27日发布),此错误“
Bad port ''
”不再存在。
See commit ad34ad6 , from commit 6b6c5f7 (by Torsten Bögershausen tboegi
) 请参阅commit 6b6c5f7 (由
tboegi
提交)提交ad34ad6
connect.c
: ignore extra colon after hostnameconnect.c
:在主机名后忽略额外的冒号Ignore an extra '
:
' at the end of the hostname in URL's like "ssh://example.com:/path/to/repo
"忽略URL中主机名末尾的额外“
:
”,如“ssh://example.com:/path/to/repo
”The colon is meant to separate a port number from the hostname.
冒号用于将端口号与主机名分开。
If the port is empty, the colon should be ignored, see RFC 3986.如果端口为空,则应忽略冒号,请参阅RFC 3986。
It had been working for URLs with
ssh://
scheme, but was unintentionally broken in 86ceb3, "allowssh://user@[2001:db8::1]/repo.git
" (Git 2.3.4).它一直在使用带有
ssh://
方案的URL,但在86ceb3中无意中断了,“允许ssh://user@[2001:db8::1]/repo.git
2.3.4)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.