美文网首页
GitHub —— fork的仓库与原仓库保持同步

GitHub —— fork的仓库与原仓库保持同步

作者: _宋江_ | 来源:发表于2020-06-15 16:16 被阅读0次

    1、查看现有的远程仓库:
    $ git remote -v
    origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
    origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)

    2、添加指向原仓库的upstream:
    $ git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git

    3、查看origin和upstream
    $ 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)

    4、直接从原仓库的master分支拉取代码并直接合并代码,其中pull=fetch+merge.
    git fetch upstream/master
    git reset --hard upstream/master

    或者直接让本地master跟随:
    git branch --set-upstream-to upstream/master

    相关文章

      网友评论

          本文标题:GitHub —— fork的仓库与原仓库保持同步

          本文链接:https://www.haomeiwen.com/subject/fshhxktx.html