How do I update a GitHub forked repository?

前端 未结 23 2656
借酒劲吻你
借酒劲吻你 2020-11-21 11:07

I recently forked a project and applied several fixes. I then created a pull request which was then accepted.

A few days later another change was made by another con

23条回答
  •  南笙
    南笙 (楼主)
    2020-11-21 11:56

    If, like me, you never commit anything directly to master, which you should really, you can do the following.

    From the local clone of your fork, create your upstream remote. You only need to do that once:

    git remote add upstream https://github.com/whoever/whatever.git
    

    Then whenever you want to catch up with the upstream repository master branch you need to:

    git checkout master
    git pull upstream master
    

    Assuming you never committed anything on master yourself you should be done already. Now you can push your local master to your origin remote GitHub fork. You could also rebase your development branch on your now up-to-date local master.

    Past the initial upstream setup and master checkout, all you need to do is run the following command to sync your master with upstream: git pull upstream master.

提交回复
热议问题