Git fetch しても新しいリモートブランチが見えない
git fetch で新しいリモートブランチが反映されないのは、--prune 不足で参照が古い・refspec が狭い・別 remote のブランチを見ようとしているの 3 系統。git fetch --all --prune と git branch -r で大半は切り分けられる。
公開: 更新:
要約
git fetch で新しいリモートブランチが見えないときは、(1) --prune 不足で参照が古い (2) refspec が狭い (3) そもそも別 remote のブランチを見ようとしている の 3 点を疑う。
最初に git fetch --all --prune を実行し、git branch -r で取得結果を確認するのが最短ルート。
よくある原因
--pruneを付けていない: リモートで削除されたブランチがローカルに残り、新規ブランチと混ざって見落とす- refspec が狭い:
remote.origin.fetchが 1 ブランチに固定されていると他ブランチは取得対象外 - 別 remote のブランチ: fork した upstream のブランチは
git remote addしていなければ見えない - ローカルとリモート追跡を混同:
git branchだけではローカルしか出ない。
リモート分はgit branch -rで見る - そもそも push されていない: 同僚がローカルブランチを作ったまま push 前で、サーバ側にまだ存在しない
解決策
1. まず --all --prune で取り直す
git fetch --all --prune
git branch -r--prune は削除済みリモート参照を整理する。--all は登録済みの全 remote を一括で fetch する(git-fetch 公式(新しいタブで開く) 参照)。
2. remote と refspec を確認する
git remote -v
git config --get-all remote.origin.fetch期待値は +refs/heads/*:refs/remotes/origin/*。
これ以外(例: +refs/heads/main:refs/remotes/origin/main)になっていると 1 ブランチしか取得しない。
3. upstream を追加する
fork 元のブランチを参照したいときは、追加 remote として登録する。
git remote add upstream https://github.com/ORG/REPO.git
git fetch upstream --prune
git branch -rgit remote の運用全般は公式リファレンス(新しいタブで開く)に詳しい。
4. ローカルにブランチを作って追跡する
git switch feature/new-branch同名リモート追跡ブランチがあれば、ローカルブランチを自動で作成し追跡する。
実行例
実際に alpine/git 環境(Git 2.54.0)で上記の手順を動かすと、git fetch --all --prune 実行後に origin/feature がリモート追跡ブランチとして現れ、終了コード 0 で正常完了することを確認できる。
warning: You appear to have cloned an empty repository.
warning: remote HEAD refers to nonexistent ref, unable to checkout$ git branch -r
origin/main$ git config --get-all remote.origin.fetch
+refs/heads/*:refs/remotes/origin/*$ git fetch --all --prune
From /tmp/tmp.FCFFnl/origin
* [new branch] feature -> origin/feature
fetch の終了コード: 0$ git branch -r
origin/feature
origin/main— 2026-08-02 時点の出力