LoginSignup
42
33

More than 5 years have passed since last update.

git fetchしてgit branch -rしてもリモートブランチが表示されなかった時

Last updated at Posted at 2017-05-15

他の人のブランチをcheckoutしようとしたができない

remoteブランチがローカルの端末上だと表示されない。git fetch しても何をしてもどうしてもremoteブランチを取得できなかった。

行き着いた先のstackoverflow
http://stackoverflow.com/questions/12319968/remote-branch-not-showing-up-in-git-branch-r

つまり gitのconfigがおかしい。
.git/config
を覗いてみると以下の通り。

  1 [core]
  2     repositoryformatversion = 0
  3     filemode = true
  4     bare = false
  5     logallrefupdates = true
  6     ignorecase = true
  7     precomposeunicode = true
  8 [remote "origin"]
  9     url = https://github.com/github_account_name/hoge.git

ここに

10     fetch = +refs/heads/*:refs/remotes/origin/*

を追加することで正しくリモートブランチをfetchすることができました。

42
33
1

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
42
33