Git push with remote ssh removed if only verbose

I have a git repository (version 2.1.2 ) with remote ssh :

 $ git remote -v origin ssh:// dettorer@dettorer.net :/home/dettorer/my_project (fetch) origin ssh:// dettorer@dettorer.net :/home/dettorer/my_project (push) 

What can not be pressed:

 $ git push Bad port '' fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 

If ... I use the --verbose switch:

 $ 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' 

In this answer, I added the ssh log level, designated as, but the output for git push (without --verbose ) was the same.

Where could this come from?

As nwinkler suggested, here is the output of two commands with 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': 

Therefore, if I do not use --verbose , there is actually an additional option '-p' with an empty argument.

EDIT: this is becoming 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. 
+5
source share
2 answers

Well, after seeing your comments, I'm sure I know what happened.

Can you change your remote url to this:

ssh:// dettorer@dettorer.net /home/dettorer/my_project

You have an extra colon, which seems to cause a problem with the extra port. I don't know why running it with -v fixes the problem.

The git help shows that the supported format is supported for the ssh protocol:

ssh://[ user@ ]host.xz[:port]/path/to/repo.git/

As you can see, a colon is only required if you need to set a port. Leave this if you want to use the standard port.

+8
source

Note: with Git 2.3.7 (released yesterday, April 27, 2015) this " Bad port '' " error no longer exists.

See commit ad34ad6 , commit 6b6c5f7 (by Torsten Bögershausen tboegi )

connect.c : ignore extra colon after host name

Ignore the extra ' : ' at the end of the hostname in the URL, for example, " ssh://example.com:/path/to/repo "

The colon is for branching the port number on behalf of the host.
If the port is empty, the colon should be ignored, see RFC 3986.

It worked for URLs using the ssh:// scheme, but was inadvertently in 86ceb3, "allow ssh:// user@ [2001:db8::1]/repo.git : ssh:// user@ [2001:db8::1]/repo.git : ssh:// user@ [2001:db8::1]/repo.git " (Git 2.3.4).

+2
source

Source: https://habr.com/ru/post/1208809/


All Articles