Git下載:https://git-for-windows.github.io/java
我下載的版本是:Git-2.6.3-64-bit.exegit
安裝:略 默認選項點擊"下一步"便可github
安裝完畢後shell
1.打開Git Bashwindows
設置使用Git時候的名字和郵箱地址ssh
$ git config --global user.name "yourname" $ git config --global user.email "youremail@email.com"
2.註冊Github帳戶:https://github.com/ide
3.設置SSH Key,在Git Bash中輸入:this
ssh-keygen –t rsa –C "github register email"
注: github register email這裏寫你在第二步註冊Github帳戶的郵箱地址spa
而後按下回車,並設置認證密碼(也可不設置)日誌
回車,會獲得兩個文件:id_rsa(私有密鑰),id_rsa.pub是公開密鑰。
這兩個文件默認在C:\Users\Username\.ssh目錄下
4.添加公開密鑰:
進入你的Github帳戶,在右上角選擇SettingàSSH keysàAdd SSH key, 其中,Title輸入一個名稱,在Key處粘貼id_rsa.pub中的內容。
5.此時就能夠用私人密鑰和Github進行認證和通訊,在Git Bash中輸入:
ssh –T git@github.com
提示:Are you sure you want to continue connecting (yes/no)?
輸入:yes 回車
顯示:Hi yourname! You've successfully authenticated, but Github does not provide shell access.
接下來,演示一個Github的HelloWorld示例:
git clone your repository's Web Address
提示:repository's Web Address就是上一步驟拷貝的URL
git add T.java
git commit –m "this is your comment"
git push
進入Github帳戶中的Hello Repository,便可查看push進去T.java這個文件
git log