一台電腦使用多個git帳號

來源:互聯網
上載者:User

標籤:查看   conf   ber   解決   cti   config   xxx   not   ica   

最近開始使用git,今天又建立了一個github帳號,提交是發現總是說第一個帳號沒有許可權,後發現git push的時候需要區分github帳號,現記錄解決方案:

1.建立SSH KEY  $ ssh-keygen -t rsa -C "[email protected]",根據提示輸入檔案名稱,如id_rsa_two,粘貼複製到github的SSH

 

2.查看使用者~/.ssh下是否存在 config檔案,如不存在使用命令 touch config建立,然後配置config

#github server one
Host github
Hostname github.com
User git
IdentityFile ~/.ssh/id_rsa
#github server two
Host github_two
Hostname github.com
User git
IdentityFile ~/.ssh/id_rsa_two

3.測試組態,測試成功後github ssh處小鑰匙表徵圖會變綠色

   ssh -T [email protected]_two   

   #如果配置正確會提示

    Hi your git account two  in  github ! You‘ve successfully authenticated, but GitHub does not provide shell access.

4.clone項目到本地

原先操作:  git clone [email protected]:yourAccount/xxx.git;

現改為:git clone [email protected]_two.com:yourAccount/xxx.git 

一台電腦使用多個git帳號

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.