2016-11-25 60 views
0

我在Github上的同一個帳戶上的一臺機器上有兩個存儲庫。我爲我的帳戶添加了一個ssh密鑰,並推送到存儲庫A,但我無法將其推送到存儲庫B.github上的SSH密鑰未與特定的repos iirc關聯。使用SSH推送到2個不同的回購使用相同的帳戶?

有點研究讓我發現我需要兩個不同的密鑰。如何編輯我的配置文件,以便git在推向第二個回購時使用正確的密鑰?

+1

加入你不要」 t需要2個鍵。你遇到了什麼錯誤? – SLaks

+0

權限被拒絕(公鑰)。但推動回購A工作正常 –

+0

確保兩個回購處於同一個帳戶下。你可以爲你的回購附加'git ls-remote --get-url origin'的輸出嗎? –

回答

0

我到了解決方案通過修改你的.ssh/config文件中附加此

Host repo2.github.com 
    User git 
    Port 22 
    Hostname github.com 
    IdentityFile ~/.ssh/id_rsa2 
    TCPKeepAlive yes 
    IdentitiesOnly yes 
    UserKnownHostsFile /dev/null 
    StrictHostKeyChecking no 

,然後通過附加下面的git的/ config文件

[remote "origin"] 
    url = [email protected]:[Username]/G2-FrontEnd.git 
    fetch = +refs/heads/*:refs/remotes/origin/* 
相關問題