What does 'git remote add upstream' help achieve?

前端 未结 4 778
说谎
说谎 2020-12-22 18:23

I was reading on: https://wiki.diasporafoundation.org/Git_workflow#Rebase_your_development_branch_on_the_latest_upstream

Here is an extract:

Y

相关标签:
4条回答
  • 2020-12-22 19:00

    I think it could be used for "retroactively forking"

    If you have a Git repo, and have now decided that it should have forked another repo. Retroactively you would like it to become a fork, without disrupting the team that uses the repo by needing them to target a new repo.

    But I could be wrong.

    0 讨论(0)
  • 2020-12-22 19:06

    The wiki is talking from a forked repo point of view. You have access to pull and push from origin, which will be your fork of the main diaspora repo. To pull in changes from this main repo, you add a remote, "upstream" in your local repo, pointing to this original and pull from it.

    So "origin" is a clone of your fork repo, from which you push and pull. "Upstream" is a name for the main repo, from where you pull and keep a clone of your fork updated, but you don't have push access to it.

    0 讨论(0)
  • 2020-12-22 19:16

    This is useful when you have your own origin which is not upstream. In other words, you might have your own origin repo that you do development and local changes in and then occasionally merge upstream changes. The difference between your example and the highlighted text is that your example assumes you're working with a clone of the upstream repo directly. The highlighted text assumes you're working on a clone of your own repo that was, presumably, originally a clone of upstream.

    0 讨论(0)
  • 2020-12-22 19:19

    Let's take an example: You want to contribute to django, so you fork its repository. In the while you work on your feature, there is much work done on the original repo by other people. So the code you forked is not the most up to date. setting a remote upstream and fetching it time to time makes sure your forked repo is in sync with the original repo.

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