LoginSignup
11
10

More than 5 years have passed since last update.

gitで他ブランチをチェックアウトできないとおもったらshallow repositoryだった

Posted at

Gitで他のブランチにチェックアウトしようとおもったのだけどなぜかできない。
よくよく考えたらテストサーバで全履歴をとってくるのは無駄なので最新の履歴しか取得してないんだった。

以下の感じに取得したリポジトリだ。

$ git clone --depth 1  git@github.com:eiel/hoge.git

.git/configをのぞいてみた。

[remote "origin"]
    url = git@github.com:eiel/hoge.git
    fetch = +refs/heads/master:refs/remotes/origin/master

masterしかとれないわけだ。
そんなわけで以下のコマンドをたたいた。

git remote set-branches  origin master goro
git fetch
git checkout goro

.git/configは以下のようになっていた。

[remote "origin"]
    url = git@github.com:eiel/hoge.git
    fetch = +refs/heads/master:refs/remotes/origin/master
    fetch = +refs/heads/goro:refs/remotes/origin/goro
11
10
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
10