LoginSignup
43
25

More than 5 years have passed since last update.

gitでリモートのブランチをローカルへ持ってくる

Posted at

他の人が作成したブランチを自分のローカルへ落としたいことがあると思います。

そのような時は以下のコマンドで実現できるという記事がたくさん見られます。

git checkout -b new-branch origin/new-branch

ただ、これはローカルリポジトリのリモート追跡ブランチにリモートリポジトリにあるものがあるということが前提です。

上記コマンドが失敗する場合はまず、リモートリポジトリにあるものをローカルリポジトリに持ってきてください。

git fetch

してください。

リモートのブランチをローカルへ持ってくるスムーズな手順としては、

git fetch
git checkout -b new-branch origin/new-branch

となります。

43
25
0

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
43
25