在Git中,當我的主機使用不同的SSH端口時,如何添加遠程原始服務器?git遠程添加其他SSH端口
git remote add origin ssh://[email protected]/srv/git/example
在Git中,當我的主機使用不同的SSH端口時,如何添加遠程原始服務器?git遠程添加其他SSH端口
git remote add origin ssh://[email protected]/srv/git/example
這不起作用,它默認爲22. – jmoz 2012-07-03 16:55:00
它確實爲我工作。我喜歡這種方法比把它放在git遙控器上更好。謝謝!無需通過這種方式指定絕對路徑。 – 2012-07-21 22:32:23
這很好。同樣,我可以有一個特定的鍵,而不是默認的id_rsa。不僅如此,我的服務器是挑剔的,或多或少你必須迅速地擁有它,如果你包含密碼就會失敗。所以我也使用'PasswordAuthentication no'。 – 2014-01-08 01:33:28
發現這個鏈接,雖然它是有幫助我的博客文章可能有助於澄清:
https://prestongarrison.com/change-port-git-is-using-for-ssh/
基本上我認爲它更好,只是編輯您的.git/config文件並進行更改。希望這會幫助別人..
您是否可以將相關代碼添加到此帖子,而不是讓用戶點擊到外部網站? – iamnotmaynard 2015-12-22 15:43:02
對於那些編輯./.git/config
[remote "external"]
url = ssh://[email protected]:11720/aaa/bbb/ccc
fetch = +refs/heads/*:refs/remotes/external/*
最佳答案對我不起作用。我需要從開始ssh://
。
# does not work
git remote set-url origin [email protected]:10000/aaa/bbbb/ccc.git
# work
git remote set-url origin ssh://[email protected]:10000/aaa/bbbb/ccc.git
Thx。只是一個補充:在路徑部分,使用絕對路徑,而不是用戶主目錄的相對路徑... – Snicolas 2012-05-28 19:54:21
@Snicolas:爲什麼不應該使用相對路徑? – Hannes 2012-05-30 19:24:40
因爲它不起作用。 – Snicolas 2012-05-30 20:10:59