1瑟由、下載Git installer絮重,
地址:http://git-scm.com/downloads
2、下載之后打開歹苦,雙擊.pkg安裝
3青伤、打開終端,使用git version命令查看安裝版本殴瘦,有就是安裝成功了
說明:Git和SVN一樣狠角,都需要創(chuàng)建一個服務(wù)器的,他們都可以創(chuàng)建自己的版本管理服務(wù)器蚪腋,對于個人和小團(tuán)隊來說丰歌,使用托管服務(wù)器可能更合適,常見的有Github 和 Bitbucket辣吃。我這里為了試驗动遭,使用了github,注:Github沒有個人免費(fèi)倉庫使用神得,代碼放上去就是開源的厘惦,如果公司有相應(yīng)的git倉庫,第4步可以省略
4哩簿、注冊github
隨手甩個鏈接:https://github.com/
5宵蕉、接下來創(chuàng)建ssh-key:
打開終端,輸入cd ~/.ssh
如果存在节榜,先將已有的ssh備份羡玛,或者將新建的ssh生成到另外的目錄下
如果不存在,通過默認(rèn)的參數(shù)直接生成ssh:
ssh-keygen -t rsa -C xxxxx@gmail.com(注冊github時的email)
(輸入完成后宗苍,按enter健即可稼稿,命令行會自動提示下面這一行??薄榛,接下來的命令行一路按enter健即可)
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/twer/.ssh/id_rsa):
Created directory '/Users/twer/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/twer/.ssh/id_rsa.
Your public key has been saved in /Users/twer/.ssh/id_rsa.pub.
The key fingerprint is:
18:16:11:c9:01:6c:48:09:7f:27:c6:43:0d:7f:3f:84 xxxxx@gmail.com
The key's randomart image is:
+--[ RSA 2048]----+
|.o.++=== |
|.ooo.+. . |
| ..* = E . |
| o = + o |
| . S o |
| . |
| |
| |
| |
+-----------------+
此時會在你的電腦里生成一個.ssh的文件,里面有你的ssh key的信息让歼,如果需要復(fù)制這個信息敞恋,可以在命令行里輸入 pbcopy < ~/.ssh/id_rsa.pub,這個是復(fù)制的命令谋右,然后打開一個文本文件硬猫,粘貼即可
6、將ssh key添加到github
登錄github后改执,
點(diǎn)擊settings后:
點(diǎn)擊new ssh key按鈕啸蜜,因為我之前添加過,所以會顯示一個ssh key
7辈挂、測試鏈接:
在命令行輸入 ssh git@github.com
如果出現(xiàn)下圖衬横,就證明已經(jīng)成功的鏈接上了
注:第一次鏈接的話,會提示這個
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终蒂,然后就可以了
8冕香、然后就可以設(shè)置個人信息啦
git config --global user.name "abc"
git config --global user.email jonezhang86@gmail.com
注:name為用戶名 email為你自己的郵箱
大功告成啦