{"meta":{"title":"为分支配置远程存储库","intro":"设置一个指向 Git 中的上游存储库的远程项，以同步分叉和原始存储库之间的更改。","product":"拉取请求","breadcrumbs":[{"href":"/zh/pull-requests","title":"拉取请求"},{"href":"/zh/pull-requests/how-tos","title":"How-tos"},{"href":"/zh/pull-requests/how-tos/work-with-forks","title":"使用分叉"},{"href":"/zh/pull-requests/how-tos/work-with-forks/configuring-a-remote-repository-for-a-fork","title":"配置远程存储库"}],"documentType":"article"},"body":"# 为分支配置远程存储库\n\n设置一个指向 Git 中的上游存储库的远程项，以同步分叉和原始存储库之间的更改。\n\n1. 打开终端或 Git Bash。\n1. 列出当前为分叉配置的远程项。\n\n   ```shell\n   $ git remote -v\n   > origin  https://github.com/YOUR-USERNAME/YOUR-FORK.git (fetch)\n   > origin  https://github.com/YOUR-USERNAME/YOUR-FORK.git (push)\n   ```\n\n1. 添加一个名为 _upstream_ 的新远程仓库，使其指向原始仓库。\n\n   ```shell\n   git remote add upstream https://github.com/ORIGINAL-OWNER/ORIGINAL-REPOSITORY.git\n   ```\n\n1. 验证为分叉指定的新上游存储库。\n\n   ```shell\n   $ git remote -v\n   > origin    https://github.com/YOUR-USERNAME/YOUR-FORK.git (fetch)\n   > origin    https://github.com/YOUR-USERNAME/YOUR-FORK.git (push)\n   > upstream  https://github.com/ORIGINAL-OWNER/ORIGINAL-REPOSITORY.git (fetch)\n   > upstream  https://github.com/ORIGINAL-OWNER/ORIGINAL-REPOSITORY.git (push)\n   ```"}