配置用戶信息
配置的是你個人的用戶名稱和電子郵件地址。這兩條配置很重要,每次 Git 提交時都會引用這兩條信息,說明是誰提交了更新,會隨更新內容一起被永久納入歷史記錄
git config --global user.name "testerDong" git config --global user.email "331157985@qq.com"
1、創建遠程倉庫,克隆遠程倉庫到本地
a.先在GitHub上創建一個遠程倉庫
b.復制該倉庫SSH地址
c.git 命令行模式 使用clone 命令,克隆遠程倉庫到本地
git clone git@github.com:testerDong/AotoTest.git
2、創建本地倉庫
a.先在本地磁盤上新建一個文件夾並進入該文件夾,然后使用git init 命令將該目錄變成本地倉庫
1 mkdir git_repository 2 cd git_repository/ 3 git init
b.在Github上創建一個空的倉庫
c.將本地倉庫與倉庫關聯,使用如下命令
git remote add origin https://github.com/testerDong/test.git
d.把本地庫的內容推送到遠程倉庫
git push -u origin master
若果本地倉庫與遠程倉庫的內容不一致則會報錯:
則需要使用如下命令解決:
1 git pull --rebase origin master 2 git push origin master
該命令的意思是把遠程庫中的更新合並到(pull=fetch+merge)本地庫中,–-rebase的作用是取消掉本地庫中剛剛的commit,並把他們接到更新后的版本庫之中。出現如下圖執行pull執行成功后,可以成功執行git push origin master操作。
該問題詳細解釋見如下文章:https://blog.csdn.net/dietime1943/article/details/85682688