1、远程仓库落后于本地仓库
本地仓库的文件经过git add . 或者进行git add+文件名 进行提交到暂存区
git commit 命令打开编辑器输入本次的更改信息
git remote+远程仓库地址 进行仓库的连接
git remote -v 进行查看
最后进行git push origin(定义的远程仓库名) master(分支)
即可完成远程仓库的更新
2、本地仓库落后于远程仓库
远程仓库由于他认得合并申请同意后的缘故,自己的本地仓库落后于远程仓库
(1)转到本地仓库所在的位置
PC@▒▒▒▒▒▒▒▒▒ MINGW64 ~/Desktop
$ cd G:\
> four-mixed-operations
(2)fetch到你的远程仓库链接
PC@▒▒▒▒▒▒▒▒▒ MINGW64 /g/four-mixed-operations (master)
$ git fetch https://github.com/Blueming-scy/four-mixed-operations
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 7 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (7/7), 2.31 KiB | 4.00 KiB/s, done.
From https://github.com/Blueming-scy/four-mixed-operations
* branch HEAD -> FETCH_HEAD
(3)fetch到仓库的主分支进行更改的读取
PC@▒▒▒▒▒▒▒▒▒ MINGW64 /g/four-mixed-operations (master)
$ git fetch origin master
From https://github.com/Blueming-scy/four-mixed-operations
* branch master -> FETCH_HEAD
806b292..ff233e2 master -> origin/master
(4)进行更新的信息与本地仓库的合并(在合并前可以进行查看是否正确)
PC@▒▒▒▒▒▒▒▒▒ MINGW64 /g/four-mixed-operations (master)
$ git merge origin/master
Updating 806b292..ff233e2
Fast-forward
1.cpp | 22 +++++++++++++++++++++-
README.md | 4 ++++
2 files changed, 25 insertions(+), 1 deletion(-)
create mode 100644 README.md
3、他人的主仓库更改自己与之同步
(1)首先通过命令进入到本地仓库所在位置
(2)添加源仓库位置进行 git remote add upstream(通常用这个) +原仓库网址
(3)进行更改的文件的抓取 git fetch upstream
(4)进行拉取的更新与本地的文件进行合并 git merge upstream/master (此步应在转到master分支后进行,如果在master分支中可忽略)
如有错误请进行指出,谢谢!!