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?
1 Answer
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 togit switch -c <branch> --track <remote>/<branch>
git branch -a(or-r) then they exist in your local repository. You can reference them by their full name, e.g.origin/somebranch. If you want to switch to a remote branch, usegit switch branchname(withoutorigin/)