Github教程(0)

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示例:

  1. 進入Github帳戶,點擊New repository
  2. Repository name輸入Hello
  3. Description項輸入一些對倉庫的描述信息(選填)
  4. Public/Private選項勾選Public
  5. Initialize this repository with a README 選項選上
  6. 點擊Create Repository便可建立一個Repository
  7. 點擊進入Hello這個Repository,拷貝這個Repository的Web Address

  8. 將Hello這個Repository clone至本地,打開Git Bash,輸入:

     

    git clone your repository's Web Address 

    提示:repository's Web Address就是上一步驟拷貝的URL

  9. Git Bash輸入cd Hello,在Hello目錄下增長一個文件,好比T.java
  10. 將T.java添加到暫存區,Git Bash中輸入:

     

    git add T.java 
  11. 提交T.java, Git Bash中輸入:

     

    git commit –m "this is your comment" 

     

  12. Push到Github上的倉庫
    git push 

     

    進入Github帳戶中的Hello Repository,便可查看push進去T.java這個文件

  13. 查看提交日誌:

     

    git log 
相關文章
相關標籤/搜索