我如何强制 git 在 ssh 到远程时使用不同的端口?

How do I force git to use a different port when ssh'ing to a remote?

我想更改远程分支的端口。我执行了这个命令

localhost:myproject satishp$ git remote add production rails@my-project.com:7822:/home/rails/myproject

但是,当我尝试推送到该分支时,我收到有关端口 22 未打开的投诉。这是真实的。它没有打开,但这就是为什么我试图在上面的声明中更改端口。

localhost:myproject satishp$ git push production master
ssh: connect to host my-project.com port 22: Connection refused
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

如何正确更改遥控器的端口?如果重要的话,Git v 2.62 在 Mac 上。

ssh:// URL 中允许端口,但 scp 中不允许。修复:

git remote set-url production ssh://rails@my-project.com:7822/home/rails/myproject