保持 fork 之后的项目和源仓库同步

This commit is contained in:
Nick
2023-11-01 16:12:26 +08:00
parent 68eed3ea23
commit 098036e8e6

10
git.md
View File

@ -204,13 +204,15 @@ git remote remove origin #取消与远程仓库关联
__保持 fork 之后的项目和源仓库同步__
```
git remote add upstream [upstream_url] #添加上游仓库 upstream 任意
git remote add upstream [upstream_url] #1、添加上游仓库命名为 upstream
git fetch upstream #拉取最新代码
git fetch upstream #2、拉取最新代码
git merge upstream/<branch_name> #将upstream/<branch_name> merge到本地当前分支
git checkout master #3、切换分支
git push origin <branch_name> #push到自己的github仓库
git merge upstream/<branch_name> #4、将 upstream/<branch_name> merge 到本地当前分支
git push origin <branch_name> #5、push 到自己的 github 仓库
```
__暂存代码__