Muhammad Kashif Nazar
Muhammad Kashif Nazar

Reputation: 23875

git clone doesn't import all remote branches

After I clone from a bare git repository, my imported local repository doesn't have all the branches in it. Following is the architecture.

enter image description here

Here are the steps how this bare repository came into being.

  1. I had an existing repository (a in the figure). I did some branch filtering within this branch to rule out some useless directories.
  2. Created a new empty bare repository (b in the figure) using git init --bare new_repo.git
  3. In the a local repository, I changed the remote URL using git remote set-url origin /path/new_repo.git.
  4. Pushed the content of a to b using the command git push origin '*:*' and got success.
  5. At this stage running the command git branch -r shows all the remote branches correctly.git branch -r
  6. Now when I clone b (bare repository), the cloned local repository (c in the figure) gets created and it has the correct directory structure. But the problem is that when I try to list all the remote branches using git branch -r, it lists only the master branch.git branch -r

Why doesn't the cloned repository have all the remote branches and how can I have all those imported?

Upvotes: 1

Views: 1401

Answers (1)

gran_profaci
gran_profaci

Reputation: 8461

git fetch origin or whatever your remote is set up to.

And then git checkout BRANCH_NAME

Upvotes: 3

Related Questions