Jeroen Wiert Pluimers Jeroen Wiert Pluimers - 1 month ago 26
Git Question

How to fetch all remote branches?

Somehow one of my repositories refuses to fetch new branches:

C:\temp>git fetch --all
Fetching origin

C:\temp>git branch -a
* develop
remotes/origin/develop

C:\temp>git ls-remote --heads origin
d130c97c1ccbe9ab35cd6e268c760781e37e3628 refs/heads/2.1.0.x
...
92685125df152fe053a2818de0c4d2ce8655c6b8 refs/heads/2.2.5.x
1e2eec16c7d63c84d6b53d0a221d22109b4de2a8 refs/heads/develop
f6447d5315fe777803b283bee7dac1dbdba92536 refs/heads/feature/0001089__icons_are_gone_-_move_inclusion_to_RC_files
e2cf0112b7e7fc18eb3467c7c42657208147efb2 refs/heads/feature/0001102__Debug_time_fix_exception_EIdSocketError_10060
6b2c89c6a39b3ce26cf42c5e8e5e0dd12c88abac refs/heads/feature/0001103__Research_cause_of_Internal_error_Stack_not_balanced
...
9f724b76b7c3533996fa03189e18a2f61fa5cf4f refs/heads/master
c233696172eb05522d1bb6705a3ea8cd730a762d refs/heads/origin/master
1db38f4fab2c41ee1931c9c6165aa6087556210a refs/heads/release
c233696172eb05522d1bb6705a3ea8cd730a762d refs/heads/trunk


How can I force
git
to fetch all these remote branches?

I'm at
git version 2.8.2.windows.1
.

Answer

Check you git config --get remote.origin.fetch refspec.

It would only fetch all branches if the refspec is

+refs/heads/*:refs/remotes/origin/*

If the refspec is:

+refs/heads/develop:refs/remotes/origin/develop

Then a fetch would only bring back the develop branch.
This is typical of a git clone --branch develop --single-branch.