2017-06-21 54 views
2

我需要連接到具有不同憑據的多個Git服務器才能工作。我有我的個人資料庫[email protected],我的辦公室工作庫[email protected]和我的客戶的工作庫[email protected]爲多個git服務器配置git客戶端

我需要經常訪問和推動代碼與不同的憑據,這些不同的存儲庫(即有機會獲得相應的資料庫)

我如何配置我的git客戶端(我在Windows上使用git shell - powershell)以每次連接到遠程存儲庫時提示我輸入用戶名和密碼?理想情況下,我寧願不必管理證書。

注意:我已經設置了我的全局變量。現在無法取消設置。

如果git bash比git shell更可取,我對此也是開放的。因爲我習慣了Windows環境,所以我只是覺得git shell更容易處理。

+0

的可能的複製(HTTPS [在同一臺計算機上的多個帳戶GitHub的?]://計算器.com/questions/3860112/multiple-github-accounts-on-the-the-computer) – Schwern

+0

如果賬號在不同的服務器上,你需要的只是每個賬號的ssh密鑰。 [Github對此有幫助](https://help.github.com/articles/connecting-to-github-with-ssh/)。如果您有多個Github帳戶,請參閱[本答案](https://stackoverflow.com/questions/3860112/multiple-github-accounts-on-the-same-computer)。 – Schwern

回答

1

您可以從.ssh/config中受益,因爲您的git帳戶在ssh之間不同。請注意領域是如何不同和密鑰指向:

#account1 
Host github.com-account-one 
    HostName github.com 
    User git 
    IdentityFile ~/.ssh/id_rsa_account_one 

#account2 
Host github.com-account-two 
    HostName github.com 
    User git 
    IdentityFile ~/.ssh/id_rsa_account_two 

例如,使用account1,請確保您設置github.com-account-one源URL或clone在本地資源庫,適當的登錄信息將遵循:

git clone ssh://[email protected]:/MyRepo/myrepo.git