![](/img/trans.png)
[英]Can I register a PuTTY key with TortoiseGit globally (not per repo)?
[英]Connecting TortoiseGit to github using different SSH credentials per repo
我在 github 上有幾個存儲庫,以及兩個不同的帳戶。 我的帳戶是下面討論的兩個存儲庫的創建者(用戶名 1 創建了存儲庫 1,用戶名 2 創建了存儲庫 2)。
如何配置 tortoisegit 以設置連接到每個 github 存儲庫時要使用的憑據(膩子密鑰)?
在 Tortoisegit > 設置 > Git > 遠程,我將 repo1 配置為:
Remote: origin
URL: git@github.com:username1/MyRepo1.git
Push URL: (blank)
Putty Key: path/to/account1.ppk
並將 repo1 配置為:
Remote: origin
URL: https://github.com/username2/myRepo2.git
Push URL: (blank)
Putty Key: path/to/account2.ppk
但是,當我嘗試推送到第一個 repo 時,出現錯誤:
git.exe push --progress "origin" master:master
ERROR: Permission to username1/MyRepo1.git denied to username2. <-- why is username2 showing up here?!?
fatal: Could not read from remote repository.
...為什么要嘗試使用 username2(未在 repo1 上的任何位置配置)進行連接? 我在哪里可以配置連接時使用的用戶名?
我嘗試更改 Tortoisegit > settings > Git 中的設置,以設置Name: username1
和Email: user1@mydomain.com
但它沒有嘗試推送相同的錯誤消息。
我已經嘗試按照TortoiseGit 的已接受答案的解釋進行操作 - Multiple GitHub repositories with different key pair each ,但是,我不知道該怎么做...
嗯......兩個鏈接上的說明都太籠統了,沒有用。 沒有具體的例子可以使用。
它基本上說“更改為'ssh'......但這只會產生新問題。我如何配置OpenSSH來建立連接?或者告訴它哪些憑據用於哪個repo?再次......沒有具體的例子。
如果我將 repo1 的連接更改為https://github.com/username1/MyRepo1.git
然后我收到錯誤fatal: unable to access 'https://github.com/username1/MyRepo1.git/': The requested URL returned error: 403
所以我將其更改為https://username1@github.com/username1/MyRepo1.git
然后我收到一個彈出窗口,要求我登錄 ZBF215181B5140522137B3D4F6B73. 我這樣做是最后的手段,它(似乎)有效,但是,我想使用 ssh 密鑰,而不是基於登錄的身份驗證。
所以......回到問題:如何配置 TortoiseGit 以使用不同的 SSH 憑據連接到不同的存儲庫?
而且,對於獎勵積分......我是否可以為 TortoiseGit 配置一組默認憑據以使用,然后在需要不同的東西時在逐個回購的基礎上覆蓋這些憑據? 如果是這樣,怎么做? (我問是因為這似乎是無意中發生的事情,所以我想知道是否有辦法故意將其用作功能!)
感謝您的閱讀,並提前感謝您的幫助!
如何配置 TortoiseGit 以使用不同的 SSH 憑據連接到不同的存儲庫?
首先,對兩個存儲庫使用 SSH URL。
由於repo2
配置了https://github.com/username2/myRepo2.git
,因此 SSH 密鑰將被忽略。
這就是為什么烏龜提到username2
如果您想使用關聯的 SSH 密鑰,則需要git@github.com:username2/myRepo2.git
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.