-
打开终端或 Git Bash。
-
列出当前为分叉配置的远程项。
$ git remote -v > origin https://github.com/YOUR-USERNAME/YOUR-FORK.git (fetch) > origin https://github.com/YOUR-USERNAME/YOUR-FORK.git (push) -
添加一个名为 upstream 的新远程仓库,使其指向原始仓库。
git remote add upstream https://github.com/ORIGINAL-OWNER/ORIGINAL-REPOSITORY.git -
验证为分叉指定的新上游存储库。
$ git remote -v > origin https://github.com/YOUR-USERNAME/YOUR-FORK.git (fetch) > origin https://github.com/YOUR-USERNAME/YOUR-FORK.git (push) > upstream https://github.com/ORIGINAL-OWNER/ORIGINAL-REPOSITORY.git (fetch) > upstream https://github.com/ORIGINAL-OWNER/ORIGINAL-REPOSITORY.git (push)
为分支配置远程存储库
设置一个指向 Git 中的上游存储库的远程项,以同步分叉和原始存储库之间的更改。