Github fork sync upstream
标签(空格分隔): git
使用场景
- fork repo
- 远程分支有改动,需要同步到fork repo上
关联远程分支
## 查看远程分支
$ git rmeote -v
## 关联远程分支
$ git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
同步远程分支
## 拉去远程分支改动到本地
git fetch upstream
## 切换到本地的主分支
git checkout main(master) 自己repo的主分支,这个分支和远程分支对应
## 本地的分支合并远程分支的改动
git merge upstream/main
参考
- https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork
- https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-repository-for-a-fork