4

I have a remote Git (Github) repo. I cloned it using the git clone command. but when I try to see the branches Using the git branch command it only shows one branch, 'main',while there is at least 15+ branches on the remote repo, which are visible via the command git branch -r. How can I get my all the remote branches into my local repo?

2

1 Answer 1

5

The idea is to not "pollute" your local branch namespace with all the remote tracking branches.

Using git branch -avv, you will see both local (main) and remote tracking branches (origin/xxx).
You can use the "guess mode" of git switch to create a local branch which will have its corresponding remote branch as upstream.

git switch <branch> 

If <branch> is not found, but there does exist a tracking branch in exactly one remote (call it <remote>) with a matching name, treat as equivalent to

git switch -c <branch> --track <remote>/<branch> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.