1、註冊Github
註冊完成之後會需要驗證郵箱才能正常使用GitHub。
註冊完成後,創建一個屬於自己的庫,包括庫的名字,以及對庫的介紹。
2、安裝Git
首先進入Git官網www.git-scm.com下載適合自己電腦的版本,執行默認安裝選項。
3、配置密鑰
在本地創建ssh key並填寫到Github網站,實現本地git與Github的認證連接。
1)執行命令:ssh-keygen -t rsa -C "[email protected]",郵箱爲註冊Github的郵箱,注意輸入對應密碼,其他選項可回車執行默認選項。
2)在c:/user/用戶名/.ssh這個文件夾下找到id_rsa.pub文件複製密鑰內容。
3)登錄Github,在Setting——SSH and GPG Keys頁面下點擊New SSH Key按鈕,取名,並粘貼密鑰內容,保存。
4)執行命令,綁定用戶信息:
ssh -T [email protected]
git config --global user.name “github-username”
git config --global user.email "you-email"
4、測試Git與Github連接
依次執行命令:
1)定位D盤根目錄
cd /D
2)創建文件夾
mkdir testProject
cd testProject
3)克隆代碼庫,增加代碼並提交
git clone https://github.com/username/test.git
cd test
echo "No Content" > test.cpp
git add test.cpp
git commit -m "test commit"
git push origin master
4)提交完畢後,打開Github網站,查看Test項目是否增加代碼文件test.cpp