Git SSH Key 產生步驟

來源:互聯網
上載者:User

it是分布式的代碼管理工具,遠端代碼管理是基於ssh的,所以要使用遠端git則需要ssh的配置。

github的ssh配置如下:

一 、

設定git的user name和email:

$ git config --global user.name "xuhaiyan"
$ git config --global user.email "haiyan.xu.vip@gmail.com"

二、產生SSH密鑰過程:
1.查看是否已經有了ssh密鑰:cd ~/.ssh
如果沒有密鑰則不會有此檔案夾,有則備份刪除
2.生存密鑰:

$ ssh-keygen -t rsa -C “haiyan.xu.vip@gmail.com”
按3個斷行符號,密碼為空白。


Your identification has been saved in /home/tekkub/.ssh/id_rsa.
Your public key has been saved in /home/tekkub/.ssh/id_rsa.pub.
The key fingerprint is:
………………

最後得到了兩個檔案:id_rsa和id_rsa.pub


3.添加密鑰到ssh:ssh-add 檔案名稱
需要之前輸入密碼。
4.在github上添加ssh密鑰,這要添加的是“id_rsa.pub”裡面的公開金鑰。

開啟https://github.com/ ,登陸xuhaiyan825,然後添加ssh。


5.測試:ssh git@github.com

The authenticity of host ‘github.com (207.97.227.239)’ can’t be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘github.com,207.97.227.239′ (RSA) to the list of known hosts.
ERROR: Hi tekkub! You’ve successfully authenticated, but GitHub does not provide shell access
Connection to github.com closed.

三、 開始使用github
1.擷取源碼:

$ git clone git@github.com:billyanyteen/github-services.git

2.這樣你的機器上就有一個repo了。
3.git於svn所不同的是git是分布式的,沒有伺服器概念。所有的人的機器上都有一個repo,每次提交都是給自己機器的repo
倉庫初始化:

git init

產生快照並存入項目索引:

git add

檔案,還有git rm,git mv等等…
項目索引提交:

git commit

4.協作編程:
將本地repo於遠端origin的repo合并,
推送本地更新到遠程:

git push origin master

更新遠程更新到本地:

git pull origin master

補充:
添加遠端repo:

$ git remote add upstream git://github.com/pjhyett/github-services.git

重新命名遠端repo:

$ git://github.com/pjhyett/github-services.git為“upstream”

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.