跳至主要内容

为分叉配置远程仓库

您必须在 Git 中配置一个指向上游仓库的远程,以 同步您在分叉中所做的更改 与原始仓库。这样也可以让您同步原始仓库中所做的更改到分叉。

平台导航

  1. 打开 终端终端Git Bash

  2. 列出您分叉当前配置的远程仓库。

    $ git remote -v
    > origin  https://github.com/YOUR-USERNAME/YOUR-FORK.git (fetch)
    > origin  https://github.com/YOUR-USERNAME/YOUR-FORK.git (push)
    
  3. 指定一个新的远程 upstream 仓库,该仓库将与分叉同步。

    git remote add upstream https://github.com/ORIGINAL-OWNER/ORIGINAL-REPOSITORY.git
    
  4. 验证您为分叉指定的新上游仓库。

    $ 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)
    
© . This site is unofficial and not affiliated with GitHub, Inc.