[英]Get new upstream branch with git
I've forked a repo and all of my work goes into that fork (my origin) and I merge branches upstream with pull requests. 我已经分叉了一个仓库,我的所有工作都进入了那个分支(我的起源),并且我将上游的分支与pull请求合并。 Pretty standard. 很标准。
But now there's a new branch in the upstream repo and I can't quite figure out how to get that new branch locally and then push it to my origin. 但是现在上游回购中有一个新分支,我无法弄清楚如何在本地获取新分支,然后将其推送到我的原点。 Here is my situation. 这是我的情况。
$ git remote show origin
* remote origin
Fetch URL: git@github.com:rackspace/jclouds.git
Push URL: git@github.com:rackspace/jclouds.git
HEAD branch: master
Remote branches:
1.5.x tracked
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
$ git remote show upstream
* remote upstream
Fetch URL: https://github.com/jclouds/jclouds
Push URL: https://github.com/jclouds/jclouds
HEAD branch: master
Remote branch:
master tracked
Local ref configured for 'git push':
master pushes to master (up to date)
I know that there is a 1.6.x branch in jclouds/jclouds and I want to get that branch locally and then push it to rackspace/jclouds. 我知道jclouds / jclouds中有一个1.6.x分支,我想在本地获取该分支,然后将其推送到rackspace / jclouds。 I've tried this command 我试过这个命令
$ git fetch upstream 1.6.x
From https://github.com/jclouds/jclouds
* branch 1.6.x -> FETCH_HEAD
And it looks like it's fetched the branch but I don't see it in git remote show
or git branch -a
so I'm unable to setup a local tracking branch. 它看起来像是获取了分支,但我没有在git remote show
或git branch -a
看到它git branch -a
所以我无法设置本地跟踪分支。
What am I missing? 我错过了什么?
This should be enough 这应该足够了
# I prefer fetching everything from upstream
git fetch upstream
# Then I track the new remote branch with a local branch
git checkout -b 1.6.x --track upstream/1.6.x
git push origin 1.6.x
If there are update issues like: 如果有更新问题,例如:
fatal: Cannot update paths and switch to branch '1.6.x' at the same time.
Did you intend to checkout 'upstream/1.6.x' which can not be resolved as commit?"
And if this doesn't work either: 如果这不起作用:
git checkout upstream/1.6.x -b 1.6.x
Then a simpler version is: 那么更简单的版本是:
# let's create a new local branch first
git checkout -b 1.6.x
# then reset its starting point
git reset --hard upstream/1.6.x
What the OP Everett Toews has to do in his case was: OP Everett Toews在他的案件中必须做的是:
Ultimately I had to explicitly add the upstream branch with 最终我必须明确添加上游分支
git remote add --track 1.6.x upstream-1.6.x https://github.com/jclouds/jclouds
and then: 然后:
git pull upstream-1.6.x 1.6.x
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.