LoginSignup
11
14

More than 5 years have passed since last update.

Gitでリモートブランチの追跡ブランチをローカルに作成する

Posted at

まずリモートリポジトリのブランチを確認します。

git branch -a

リモートにあるはずのブランチが見えないときもあります。

そんなときは

git remote show origin

リモートブランチを確認すると、追跡できていないブランチ名の横にnew(next fetch will store in remotes/origin)とつきます。

メッセージに従い、以下のようにfetchします。

git fetch --all

これでgit branch -aで見えなかったリモートのブランチが見えるようになります。

最後に-tオプションをつけてcheckoutすることで、リモートブランチの追跡ブランチを作成できます。

git checkout -t origin/[リモートブランチ名]

以上

11
14
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
11
14