Take the 2-minute tour ×

I've created a new empty gitolite repo into which I want to push a snapshot (on my workstation) of my original git repo. I followed the instructions to do git push --all followed by git push --tags. This seemed to work great, but I find that some branch references didn't get pushed. Running git show-ref on my workstation shows a number of refs of the sort refs/remotes/origin/branchXyz, but doing git show-ref directly on the gitolite repo doesn't show this branch name at all (I expected to see it appear as refs/heads/branchXyz. How can I push the remaining branches?


share|improve this question

1 Answer 1

If your local repo was itself a clone (of 'origin', another non-gitolite repo), it didn't have all the branches locally, only references to remotes ('origin') branches.

You should first pull all branches or track them all:

$ git remote update  
$ git pull --all

# or:

remote=origin ; for brname in `git branch -r | grep $remote | grep -v master | grep -v HEAD | awk '{gsub(/[^\/]+\//,"",$1); print $1}'`; do git branch --set-upstream $brname  $remote/$brname ; done

(The last command is detailed here)

(Both options are also detailed in "Track all remote git branches as local branches", and in "Can “git pull --all” update all my local branches?" or "How do I clone all remote branches with Git?")

Then push --all to your new (gitolite) upstream repo.

share|improve this answer
Thanks for the answer, and also thanks for all the useful links. I was under the impression that git fetch pulled the history of the whole repository and that, therefore, I would have all of the remote branches as well. If I understand correctly, this is wrong; git fetch will only pull the history for the remote branches that are tracked. git clone is insufficient, I would also need to do a git pull --all before having any hope of being able to do a git push --all. Is that right? –  torngat Jun 1 '12 at 15:38
@torngat no, git fetch pull all branches too (they are in remotes/origin/heads), you are just not tracking them, and git push --all pushes only tracked branches (the ones in refs/heads/). Look at git branch -a after a git fetch –  KurzedMetal Jun 1 '12 at 15:42
@tornga > git fetch pull all branches too: yes, but not tracked by local branches. Hence your issue after pushing to gitolite. –  VonC Jun 1 '12 at 15:50
@VonC git remote update and git pull -all had no visible effect (git branch) still doesn't report any other local branch than master. However, the other command you suggested did seem to have an effect. But I'm puzzled by the messages. Here's an example: Branch origin/BR_EM_141 set up to track local branch master. Does this mean that I have a local branch named BR_EM_141 that is tracking master? I want it to track remote BR_EM_141. –  torngat Jun 1 '12 at 16:50
@torngat: that means the second command isn't exactly working as intended. I have replaced in my own (answer edited), with a link to stackoverflow.com/a/6300386/6309 which explains it. –  VonC Jun 1 '12 at 17:48

Your Answer


