Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fetch all remote branches?

Tags:

git

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.

like image 911
Jeroen Wiert Pluimers Avatar asked Oct 10 '16 11:10

Jeroen Wiert Pluimers


People also ask

Does git fetch pull all branches?

Thanks for the lead! git fetch -all fetches all branches of all remotes. git fetch origin fetches all branches of the remote origin .

What is the git command to see all the remote branches?

The git remote -r command lets you see a list of all the branches on a particular remote. If you need more information about the remotes associated with a repository, you can use the git remote show command.

How do I get all branches in a repository?

1 Answer. git fetch --all and git pull -all will only track the remote branches and track local branches that track remote branches respectively. Run this command only if there are remote branches on the server which are untracked by your local branches.

Which command can be used to fetch all of the branches from the repo?

The git fetch command allows to fetch all branches simultaneously from a remote repository.


Video Answer


2 Answers

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.

like image 124
VonC Avatar answered Oct 21 '22 23:10

VonC


you can check your branch cat .git/config in terminal

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
[remote "origin"]
    url = { git remote url }
    fetch = +refs/heads/develop:refs/remotes/origin
[branch "develop"]
    remote = origin
    merge = refs/heads/develop

and git remote update but not update remote branch. you will replace origin fetch

first, check remote fetch git config --get remote.origin.fetch

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

second, unset remote fetch use git config --unset-all remote.origin.fetch and add another git config --add remote.origin.fetch +refs/heads/\*:refs/remotes/origin/feature/\*

then, you can check replace remote git config --get remote.origin.fetch

+refs/heads/*:refs/remotes/origin/*
like image 42
홍성호 Avatar answered Oct 21 '22 22:10

홍성호