Skip to main content

为复刻配置远程仓库

You must configure a remote that points to the upstream repository in Git to sync changes you make in a fork with the original repository. 这也允许您将在原始仓库中所做的更改同步到复刻中。

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