11

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: gitolite@git.uio.no:***
  Push  URL: gitolite@git.uio.no:***
  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. )

Ajedi32
  • 45,670
  • 22
  • 127
  • 172
Mixopteryx
  • 1,098
  • 1
  • 12
  • 18

1 Answers1

22

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
hd84335
  • 8,815
  • 5
  • 34
  • 45
Mixopteryx
  • 1,098
  • 1
  • 12
  • 18
  • 1
    If you don't mind me asking, how did the configuration become `+refs/heads/master:refs/remotes/origin/master` in the first place? – nishantjr May 10 '17 at 16:31
  • 1
    Good question. Unfortunately, I have no idea. I don't remember doing anything that should affect that configuration. – Mixopteryx May 10 '17 at 18:29
  • 2
    Nasty issue that made me spend an afternoon with endless, cryptic errors, like "merge: origin/master - not something we can merge" and "merge: origin/master - not something we can merge". This solution fixed it! I am including the error strings for posterity, so the next git victims... ehm... users may find the connection and thank both you and me for that – Dario Fumagalli Jan 24 '18 at 18:36
  • 3
    @Mixopteryx this happend to me when I cloned the repository with --depth; apparently this happens also if you use --single-branch while cloning – petrpulc Jun 22 '18 at 13:24