Pull new updates from original GitHub repository into forked GitHub repository

后端 未结 8 811
梦谈多话
梦谈多话 2020-11-22 07:08

I forked someone\'s repository on GitHub and would like to update my version with commits and updates made in the original repository. These were made after I forked my copy

8条回答
  •  盖世英雄少女心
    2020-11-22 07:41

    You have to add the original repository (the one you forked) as a remote.

    From the GitHub fork man page:

    fork

    Once the clone is complete your repo will have a remote named “origin” that points to your fork on GitHub.
    Don’t let the name confuse you, this does not point to the original repo you forked from. To help you keep track of that repo we will add another remote named “upstream”:

    $ cd github-services
    $ git remote add upstream git://github.com/pjhyett/github-services.git
    $ git fetch upstream
    
    # then: (like "git pull" which is fetch + merge)
    $ git merge upstream/master master
    
    # or, better, replay your local work on top of the fetched branch
    # like a "git pull --rebase"
    $ git rebase upstream/master
    

    You have also a ruby gem which can facilitate those GitHub operations.

    forked

    See also "Git fork is git clone?".

提交回复
热议问题