Git安裝
可檢視我之前寫過的博文
設定SSH key
檢視ssh key
可以先檢視一下是否已經生成過ssh key

生成ssh key
$ ssh-keygen -t rsa -C "youremail@xxx.com"
複製程式碼
生成過程中點選Enter鍵三次,此時在預設路徑會生成.ssh資料夾,裡面有如圖三個檔案

檢視id_rsa.pub

為GitHub賬號配置ssh key
Settings
點選頭像,下拉框中有個Settings設定選項

Personal settings
在Personal settings選擇 SSH and GPG keys

New SSH key
點選New SSH key

SSH keys/Add new

Add後

建立本地倉庫
建立
mkdir test
cd f:test
複製程式碼

初始化本地倉庫
git init
複製程式碼


新增
將所有檔案新增到倉庫
git add .
複製程式碼
提交
提交,雙引號內是提交註釋
git commit -m 'first'
複製程式碼

連線GitHub
建立一個新的倉庫
-
登入GitHub賬號,沒有可以申請一個。點選右上角“+”,選擇建立一個倉庫
-
定義Repository name,點選建立
-
建立完之後的倉庫
連線GitHub
git remote add origin https://github.com/nullcxy/First-Repository.git
複製程式碼

將檔案推送到遠端倉庫
$ git push -u origin master
複製程式碼
剛開始的時候遠端倉庫是空的,所以需要加上“-u”這個引數,下次再push就不需要了,如下即可
$ git push origin master
複製程式碼

看一下遠端倉庫
