4

I have only basic knowledge in git.

I only cloned single branch from my remote using command line and following command (the repository has multiple branches at the time of cloning)

git clone <url> --branch <branch> --single-branch

I am able to do all git operations using my android-studio IDE vcs support to the cloned branch. Now I want to switch my remote branch but my android-studio IDE not showing the remote branches. It is showing only one branch that i used to clone. From the searches I had I checked the following solutions but doesn't work.

Refresh remote Git branches in Android studio

How can I get the list of remote branches without cloning the master branch from the scratch?

James Z
  • 11,838
  • 10
  • 25
  • 41
Muhamed Riyas M
  • 4,707
  • 3
  • 24
  • 29

1 Answers1

5

You are only seeing one branch, because you used --single-branch

From the git documentation:

--[no-]single-branch

Clone only the history leading to the tip of a single branch, either specified by the --branch option or the primary branch remote’s HEAD points at. Further fetches into the resulting repository will only update the remote-tracking branch for the branch this option was used for the initial cloning. If the HEAD at the remote did not point at any branch when --single-branch clone was made, no remote-tracking branch is created.

To undo this:

git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch origin

To add a single branch:

git remote set-branches --add origin [remote-branch]
git fetch origin [remote-branch]:[local-branch]
Fabian H.
  • 760
  • 5
  • 18