在GitHub上創建一個repository。
1.首先,生成私鑰和公鑰:
$ ssh-keygen -t rsa -C “[email protected]” (最好填寫gitHub的註冊郵箱)
這裏有個關鍵的地方:SSH,待會會用到。
2.將本地的Git關聯到GitHub
在本地命令行中:git remote add origin [email protected]:ZQ-jhon/test.git
即可關聯遠程倉庫(這裏的[email protected]對應上圖。)
狂敲回車,然後在C:/Administrator下會生成一個.ssh文件夾,找到裏面_pub的文件,記事本打開,全部ctrl+c,來到:
gitHub—–>Settings——>SSH and GPG keys ,點New SSH Key ,title隨便取個名字,底下內容粘貼剛纔複製的_pub文件,OK。
OK,至此,兩個庫已經關聯起來了。關聯的GitHub項目庫僅僅是名爲test的這個庫。
3.將本地庫推到GitHub中。
$ git push -u origin master
4.提示信息
第一次關聯推送時,提示:
The authenticity of host 'github.com (xx.xx.xx.xx)' can't be established.
RSA key fingerprint is xx.xx.xx.xx.xx.
Are you sure you want to continue connecting (yes/no)?
輸入yes,回車,OK,現在遠程倉庫和本地倉目錄一摸一樣了。
以後每次推送,只需要$git push origin master就行。