Skip to main content
We publish frequent updates to our documentation, and translation of this page may still be in progress. For the most current information, please visit the English documentation.

为分支配置远程存储库

必须在 Git 中配置指向上游存储库的远程存储库,才能将你在分支中所做的更改同步到原始存储库。 这也允许您将在原始仓库中所做的更改同步到复刻中。

  1. 打开终端终端Git Bash
  2. 列出当前为复刻配置的远程仓库。
    $ git remote -v
    > origin  https://HOSTNAME/YOUR_USERNAME/YOUR_FORK.git (fetch)
    > origin  https://HOSTNAME/YOUR_USERNAME/YOUR_FORK.git (push)
  3. 指定将与分支同步的新远程上游存储库。
    $ git remote add upstream https://HOSTNAME/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
  4. 验证为复刻指定的新上游仓库。
    $ git remote -v
    > origin    https://HOSTNAME/YOUR_USERNAME/YOUR_FORK.git (fetch)
    > origin    https://HOSTNAME/YOUR_USERNAME/YOUR_FORK.git (push)
    > upstream  https://HOSTNAME/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
    > upstream  https://HOSTNAME/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)