git clone Bitbucket repo only gets master branch, not whole thing

Zlatko Kajan June 27, 2019

git clone <bitbucket sever url>/<repo name>.git

Gets us the repo with just the master branch in it.  If we try to switch to another branch, have to grab it from server individually to be a local copy of the branch.

 

Doing git clone <Repo> from a standalone GIT server gets all the branches to be a local copy.

 

Is there a setting somewhere in Bitbucket that would enable the "get all the branches" behavior, or some flag that can be passed to it to do so?

 

Using Bitbucket 5.6.1 if it matters (our IT is working to get us to latest but... slow).

2 answers

1 accepted

0 votes
Answer accepted
Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 27, 2019

What you see is expected Git behavior, when you clone a repository it will create a local copy of the master branch. If you do a git branch -a you will see that you have access to all remote branches.

As @Edwin Kyalangalilwa mentioned you can use git checkout branch, this will create a detached HEAD state, since you are checking out a remote branch. If you use git checkout -t origin/branch it will setup a local copy and track it to the remote.

Zlatko Kajan July 2, 2019

Thank you Mikael, upon further playing around with GIT we realized we had a fundamental misunderstanding of what clone was supposed to do.

0 votes
Edwin Kyalangalilwa
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 27, 2019

Hi @Zlatko Kajan ,

Use checkout to switch to another branch

git checkout branch
Zlatko Kajan June 27, 2019

No, i understand that, but that gives me that one branch only.

 

The purpose of checking out everything is because a developer on a project will be going on travel and needs to have multiple branches available so they can keep working while they are away from the Bitbucket server which is physically not connected to the Internet.

 

Are you saying the only way to get all branches to checkout locally is to check them out one by one?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events