私はリポジトリをフォークし、私の作業はすべてそのフォーク (私の origin) に入り、プル リクエストを使用して上流のブランチをマージします。かなり標準的です。
しかし、アップストリーム リポジトリに新しいブランチが追加され、その新しいブランチをローカルに取得して origin にプッシュする方法がよくわかりません。これが私の状況です。
$ git remote show origin
* remote origin
Fetch URL: [email protected]:rackspace/jclouds.git
Push URL: [email protected]: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)
jclouds/jcloudsに1.6.xブランチがあることはわかっています。そのブランチをローカルで取得して、rackspace/jcloudsにプッシュしたいと考えています。次のコマンドを試しました。
$ git fetch upstream 1.6.x
From https://github.com/jclouds/jclouds
* branch 1.6.x -> FETCH_HEAD
ブランチは取得されたように見えますが、それが表示されないgit remote show
ためgit branch -a
、ローカル追跡ブランチを設定できません。
何が足りないのでしょうか?
ベストアンサー1
これで十分だろう
# 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
次のような更新の問題がある場合:
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?"
それでもうまくいかない場合は、次の手順に従ってください。
git checkout upstream/1.6.x -b 1.6.x
よりシンプルなバージョンは次のようになります。
# 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
何だOP エヴェレット・トーウズ彼の場合、次のことが関係していました。
最終的には、上流ブランチを明示的に追加する必要がありました。
git remote add --track 1.6.x upstream-1.6.x https://github.com/jclouds/jclouds
その後:
git pull upstream-1.6.x 1.6.x