The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,482 other followers

When git fails to `fetch all`

Posted by jpluimers on 2018/10/26

“fetch all”

A SourceTree fetch all actually comes down to this:

git -c diff.mnemonicprefix=false -c core.quotepath=false fetch --tags origin

Despite being such a big command-line, it sometimes doesn’t find new remote branches and you end up with a situation like this:

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

C:\temp>git branch -a
* 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

A git fetch --all normally does catch them unless your git config remote.origin.fetch returns a wrong value (thanks VonC [WayBack] for answering this in git – How to fetch all remote branches? – Stack Overflow [WayBack] and teaching me about the git Refspec [WayBack]):

C:\temp>git config remote.origin.fetch

The fix is simple:

C:\temp>git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/*

C:\temp>git fetch --all
Fetching origin
remote: Counting objects: 4006, done.
remote: Compressing objects: 100% (1404/1404), done.
remote: Total 3497 (delta 2249), reused 2936 (delta 2057)R
Receiving objects: 100% (3497/3497), 13.27 MiB | 1.71 MiB/s, done.
Resolving deltas: 100% (2249/2249), completed with 188 local objects.
 * [new branch] 2.1.0.x -> origin/2.1.0.x
 * [new branch] 2.2.1.x -> origin/2.2.1.x
 * [new branch] 2.2.2.x -> origin/2.2.2.x
 * [new branch] 2.2.3.x -> origin/2.2.3.x
 * [new branch] 2.2.4.x -> origin/2.2.4.x
 * [new branch] 2.2.5.x -> origin/2.2.5.x
 * [new branch] master -> origin/master
 * [new branch] origin/master -> origin/origin/master
 * [new branch] release -> origin/release
 * [new branch] trunk -> origin/trunk



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: