[英]git push with ssh remote fails unless verbose
我有一個帶有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)
哪個沒能推:
$ 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
日志級別的增加,但是git push
(沒有--verbose
)的輸出完全相同。
哪里可以來的?
正如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.
好的,看到你的評論后,我很確定我知道什么是錯的。
您可以嘗試將遠程URL更改為:
ssh://dettorer@dettorer.net/home/dettorer/my_project
你在那里有一個額外的冒號,這似乎導致了額外端口的問題。 我不知道為什么用-v
運行它來修復問題。
git幫助顯示以下是ssh
協議支持的格式:
ssh://[user@]host.xz[:port]/path/to/repo.git/
如您所見,只有在需要設置端口時才需要冒號。 如果要使用標准端口,請將其關閉。
注意:使用Git 2。3。7(昨天,2015年4月27日發布),此錯誤“ Bad port ''
”不再存在。
請參閱commit 6b6c5f7 (由tboegi
提交)提交ad34ad6
connect.c
:在主機名后忽略額外的冒號忽略URL中主機名末尾的額外“
:
”,如“ssh://example.com:/path/to/repo
”冒號用於將端口號與主機名分開。
如果端口為空,則應忽略冒號,請參閱RFC 3986。它一直在使用帶有
ssh://
方案的URL,但在86ceb3中無意中斷了,“允許ssh://user@[2001:db8::1]/repo.git
2.3.4)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.