我 fork 了一个 GitHub 项目。我想创建一个新分支,它是原始项目主分支的克隆(主分支有我上次 fork 时的新提交)。
我该怎么做?
最佳答案
首先你需要configure a remote for a the original repo .
$ git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
$ git fetch upstream
现在您可以对原始仓库中的任何分支使用任何 git 命令。
$ git checkout master
$ git pull upstream master
当然,您可以 checkout 除 master 以外的任何其他分支。
$ git checkout my-radical-new-feature
$ git pull upstream master
通常我会直接 pull 到我的本地 master 分支,如此处所示,然后将本地 master merge 到我工作的其他分支。
$ git checkout master
$ git pull upstream master
$ git checkout my-radical-new-feature
$ git merge master
参见 the GitHub docs了解更多详情
关于git - 如何将原始 GitHub 项目的分支克隆到您的复刻中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44683831/