Git Tracking Upstream

孤街醉人 提交于 2019-11-30 07:25:15

Read the "Step 3: Configure remotes" of the GitHub "Fork a Repo" page (I know you didn't mention GitHub, but it is still relevant)

  • origin is the remote address of your fork, that your local clone can pull from/push to
  • upstream is the remote address of your original repo Skeleton (you can add it with a git remote add upstream https://..../Skeleton.git)

So upstream isn't a branch.

But you can define a local branch which will have for upstream branch the remote tracking branch master from upstream repo, with git branch:

git branch --set-upstream upstream_master upstream/master

However, you don't need a local branch, especially if you won't ever make new commits on it: you can compare your master with upstream/master directly, after a git fetch upstream, cherry-picking what you need from upstream/master.

According to your description, you should rebase the forks on the skeleton whenever it changes, using

$ git rebase upstream

This will transform the situation as follows

initially:
1 - 2 - 3 <- upstream
        \- 4 <- fork

upstream changes:
1 - 2 - 3 - 5 - 6 <- upstream
        \- 4 <- fork

after rebase:
1 - 2 - 3 - 5 - 6 <- upstream
                \- 4 <- fork

In other words, your fork will look like as if it were forked from the most recent version of the skeletton.

The disadvantage of this approach is that it changes the history of the forks... If you don't want this, you can just merge upstream into fork (no need to cherry-pick I think).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!