あなたの質問の言い回しは少しわかりにくいと思いますが、これが正しいかどうか見てみましょう。
repo
いくつかの元のマシンから複製されたレポがありますO
。
- では、 を追跡し
repo
ているローカル ブランチ、つまりonという名前のブランチがあります。あなたはそれに取り組んでいます ( )。b
origin/b
b
O
git checkout b
- ここで、新しいブランチ を作成します
nb
。に分岐はありませnb
んO
。
nb
存在しないブランチを追跡したいorigin/nb
。
origin/nb
はまだ存在しないため、最後のステップは (まだ) 不可能です。最初に作成する必要があります(git push -u
上記のコマンドのように)。でプッシュすると、-u
が作成nb
されO
、さらに (ローカルで)origin/nb
の上流ブランチが作成され、設定さnb
れorigin/nb
ます。
アップストリームを設定しようとする場合は、次の点に注意してください。
$ git checkout -b nb
... optionally, add various commits here ...
$ git branch --set-upstream-to=origin/nb
エラーが発生します:
error: the requested upstream branch 'origin/nb' does not exist
hint:
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run "git fetch" to retrieve it.
hint:
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: "git push -u" to set the upstream config as you push.
したがって、代わりに、上記で提案したことを正確に実行する必要があり、「ヒント」に示されています。
$ git checkout -b nb
... optionally, add various commits here ...
$ git push -u origin nb
Counting objects: 10, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (7/7), 633 bytes | 0 bytes/s, done.
Total 7 (delta 2), reused 0 (delta 0)
To ssh://[redacted]
* [new branch] nb -> nb
Branch nb set up to track remote branch nb from origin.