7

If I do

$ git clone https://github.com/dtu-compute/docker-mongodb
$ cd docker-mongodb
$ git branch
* master

but if you look at the Github branch page, there are two branches.

Question

Why don't I get all the branches with git clone?

Tim
  • 38,263
  • 17
  • 115
  • 131
Jasmine Lognnes
  • 5,229
  • 7
  • 33
  • 48
  • 4
    if you checkout the branch you will see it works fine – Tim Jun 09 '16 at 15:02
  • But why isn't it listed? have it something to do how the branch were pushed? – Jasmine Lognnes Jun 09 '16 at 15:04
  • 7
    `git branch -a` will list all of them – Tim Jun 09 '16 at 15:04
  • 2
    If a remote repo has no master branch, you may ask why `git clone` clones nothing. In fact, it clones everything if no option like --single-branch or --depth is used. They are hidden at first. `git branch` only lists the local branches. – ElpieKay Jun 09 '16 at 15:11

1 Answers1

10

git branch only shows local branches by default; use git branch -r to see remote branches or git branch -a to see all. git clone only creates one local branch, master by default, which tracks (again, by default) the master branch on the remote repository.

chepner
  • 389,128
  • 51
  • 403
  • 529