LoginSignup
2

More than 3 years have passed since last update.

git cloneしたものとは違うブランチを見たい場合の対処法

Last updated at Posted at 2019-11-15

たとえばこんなケースです

  • Aさん「私のコードをチェックして。masterブランチよ」
  • わたし
$ git clone https://github.com/a_san/test.git
  • Aさん「ごめん!developブランチだったわ!」
  • わたし 😩

対処法

①リモートのブランチ一覧を確認する

$ git branch -r

たとえばこんな感じになる

$ git branch -r
  origin/HEAD -> origin/master
  origin/master
  origin/develop  # 今回はこれが目的のブランチ

②該当のブランチに切り替える

$ git checkout [リモートブランチ名]
$ git checkout develop 

結論

cloneすることで、全ブランチの情報が手元に存在することになる

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2