GitHub--Syncing a fork

  1. git remote -v — 查看所有远程主机及地址

    1
    2
    3
    $ git remote -v
    origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
    origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
  2. git remote add upstream — 添加远程主机

    1
    $ git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git

    查看添加后远程主机 — git remote -v

    1
    2
    3
    4
    5
    $ 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)
  3. git fetch upstream — 从远程获取最新版本

  4. git checkout master — 确保在master分支

  5. git merge upstream/master — 将upstream/master上的更改合并到本地master分支