LoginSignup
9
2

More than 1 year has passed since last update.

shallow clone 後にすべてのリモートブランチを取得する

Posted at

shallow clone だとリモートブランチが取得されない

$ git clone --depth 1 git@github.com:MtDeity/example.git
Cloning into 'example'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.

shallow clone した後に

$ git fetch --unshallow

をしても、

$ git branch --remote
  origin/HEAD -> origin/main
  origin/main

リモートブランチの一覧を表示すると、デフォルトブランチしか取得されていない。

すべてのブランチをリモートで追跡する

下記のコマンドで、すべてのブランチをリモートで追跡するように変更する。

$ git remote set-branches origin '*'

その後、

$ git fetch

をすると、すべてのブランチが取得される。

$ git branch --remote
  origin/HEAD -> origin/main
  origin/develop
  origin/main

参考

branch - git shallow clone (clone --depth) misses remote branches - Stack Overflow

9
2
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
9
2