Updating forked GitHub repo to match original's latest code and commits

后端 未结 1 1028
走了就别回头了
走了就别回头了 2020-12-12 22:48

I forked a GitHub project several days ago and from its issues, I can see that the master branch has had some modifications since.

When I cd to my loca

相关标签:
1条回答
  • 2020-12-12 23:36

    When you fork a repository, a copy of the original repository is established on your GitHub account. This permits read+write access to the "copy".

    When the original repository resource has commits that would benefit your copy, follow these steps to update your fork's master branch. You could update other branches, but typical workflow is to update master against the original repository.

    1. Open a Terminal
    2. cd to your project directory
    3. git remote add upstream <url-of-original-repository>
    4. git branch and verify you are on master branch
    5. git pull --rebase upstream master

    Step #5 will fetch all new commits of the "original" repository, apply them to master branch from the last merge-base, then include all of your branch's commits "on top".

    Any time you need to update your fork again, simply run the command in step #5.

    0 讨论(0)
提交回复
热议问题