A premise in your question is incorrect:
I have use git clone {url}, and it only clone the master/main branch.
By default, a clone will include every branch that is in the remote repo. After you clone a repo, you will have a single branch checked out (typically main
or master
). If you run the command:
git branch
you will only list your local branches. All of the other branches are there on your local clone, and to view all local and remote tracking branches you should use the --all
option:
git branch --all
You can switch
to (or checkout
) any of those branches if you want to work on them. Otherwise you can view their logs to see what interests you.
More info about listing branches is documented here.