これは、ローカルブランチが追跡しているリモートブランチを見つけることではありません 。複数のリモートがある場合は、それらすべてに「マスター」が含まれている可能性があります。 マスターを返しますが、私が使用しているマスターブランチがremoteFooにあるのかremoteBarにあるのかわかりません。たとえば、次のようにします。git branch
git clone someRepo.git
cd someRepo
git remote add anotherRemote otherremoteURL
その後、git remote
ショー
someRepo
anotherRemote
どちらの場合も、「マスター」と言うことができますgit checkout -b master someRepo/master
。最初の部分である「someRepo」または「anotherRemote」を取り戻すにはどうすればよいですか?git checkout -b master anotherRemote/master
git branch
私が使用できると思うかもしれませんgit remote show
が、引数、つまり情報が必要なリモートの名前が必要です。
$ git remote show origin
fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
$ git remote show
someRepo
anotherRemote
git branch
私は現在何が起こっているのかを知ることができます:
$ git branch
hold
* master
old-stuff
refactor
git remote
ただし、出力には「*」はありません。