Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git fetch does not download remote branches

Tags:

git

I cannot get Git to fetch new branches on the remote. git remote show will not show that any branch other than master exists, but git ls-remote proves that they exist.

Example: git ls-remote shows that the branch homodyne_process exist-

$ git ls-remote origin
b935ee960a588144d3df0f08a82b81ea705c7543        HEAD
f11bd3ac9c2345a12edb9d49cd5bd027616b2226        refs/heads/homodyne_process
b935ee960a588144d3df0f08a82b81ea705c7543        refs/heads/master

Fetch updates and show remote branches

$ git fetch
$ git remote show origin
* remote origin
  Fetch URL: [email protected]:***
  Push  URL: [email protected]:***
  HEAD branch: master
  Remote branch:
    master tracked
  Local branches configured for 'git pull':
    master        merges with remote master
  Local refs configured for 'git push':
    homodyne_process pushes to homodyne_process (fast-forwardable)
    master           pushes to master           (up to date)
$ git branch -r
  origin/master

I managed to get the homodyne_process pushes (...) line after running

git pull origin homodyne_process:homodyne_process

but it still won't show that the remote branch does exist. Why does this happen?

I have also tried any git fetch origin homodyne_process and lots of combinations, but the branch origin/homodyne_process will not appear.

I am working on windows and the repo is hosted via gitolite.

(I have removed some other branches from the output, for brevity. )

like image 551
Mixopteryx Avatar asked Oct 30 '14 09:10

Mixopteryx


People also ask

Does git fetch update remote branches?

Fetch command will retrieve all changes from the remote branch which do not exist in the local branch.

Does git fetch download all branches?

Git fetch commands and optionsFetch all of the branches from the repository. This also downloads all of the required commits and files from the other repository. Same as the above command, but only fetch the specified branch. The --dry-run option will perform a demo run of the command.

How do I fetch all remote branches?

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. Thus, you can fetch all git branches.

Does git fetch get new branches?

fetch will not update local branches (which track remote branches); if you want to update your local branches you still need to pull every branch. fetch will not create local branches (which track remote branches), you have to do this manually.


1 Answers

This answer solved my question: https://stackoverflow.com/a/25941875/1982894.

Basically I needed to run

git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"

This sets git to fetch all remote branches and not just master. The original configuration was:

$ git config --get remote.origin.fetch
+refs/heads/master:refs/remotes/origin/master
like image 190
Mixopteryx Avatar answered Sep 17 '22 14:09

Mixopteryx