How can I keep my fork in sync without adding a separate remote?

Let's assume there is a repository someone/foobar on GitHub, which I forked to me/foobar .

How do I pull new commits from the parent repository directly to my fork , without having to add a separate remote and remember to pull regularly from there ?

The goal is to:

  • git pull to fetch from the parent repository
  • git push to send everything to my fork

  • Open the forked Git repository me/foobar .

    Click on Compare:

    以下是该页面的示例图像

    You will get the notification "There isn't anything to compare. someone/foobar is up to date with all commits from me/foobar . Try switching the base for your comparison."

    Click on switching the base on this page:

    这是一个在页面上的例子

    Then you get to see all the commits made to someone/foobar after the day you forked it.

    Click on "Click to create a pull request for this comparison":

    这里是一个示例页面

    Give the pull request a title and maybe a description and click send pull request.

    On the next page, scroll to the bottom of the page and click merge pull request and confirm merge.

    Your Git repository me/foobar will be updated.


    git remote set-url origin git@github.com:someone/foobar
    git remote set-url origin --push git@github.com:me/foobar
    

    There is one caveat though:
    This is perfect if you are the only one making changes to your fork.
    However, if it is shared with other people, you may have to pull from your fork, in which case a separate remote is the only solution.

    Edit:
    Actually, you can git pull git@github.com:me/foobar , which removes the caveat.
    The choice is yours as to which is easier to remember.


    I used a fairly simple method using the GitHub Web UI to do that:

  • Open the original Git repository (not the forked Git repository me/foobar )
  • Jump to the src folder, and open the file you want to change
  • Click the pen icon. It will automatically create a label in your personal fork named "patch-1" based on the current version of the master repository: 在这里输入图片说明
  • Enjoy! 在这里输入图片说明
  • 链接地址: http://www.djcxy.com/p/18070.html

    上一篇: 显示已经在目标分支中的提交的GitHub拉取请求

    下一篇: 我怎样才能保持我的叉同步,而无需添加单独的远程?