- 查看配置
$ git remote -v
origin http://ForkProject.git (fetch)
origin http://ForkProject.git (push)
- 添加源项目地址
$ git remote add upstream http://SourceProject.git(源项目地址)
- 查看添加源项目地址后的配置
$ git remote -v
origin http://ForkProject.git (fetch)
origin http://ForkProject.git (push)
upstream http://SourceProject.git(fetch)
upstream http://SourceProject.git(push)
- 获取源项目更新
$ git fetch upstream
remote: Counting objects: 15, done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 15 (delta 14), reused 0 (delta 0)
Unpacking objects: 100% (15/15), done.
From http://SourceProject
* [new branch] branchA -> upstream/branchA
* [new branch] master -> upstream/master
- 合并源项目更新
$ git merge upstream/branchA(需要同步的分支)
Updating 462352a..4a23f6a
Fast-forward
FileA.txt | 6 +++---
FileB.sh | 2 +-