If I do
$ git clone https://github.com/dtu-compute/docker-mongodb
$ cd docker-mongodb
$ git branch
* master
but if you look at the Github branch page, there are two branches.
Question
Why don't I get all the branches with git clone
?
While you can clone repositories with the git clone command, keep in mind that this clones the branch and the remote HEAD . This is usually master by default and includes all other branches in the repository. So when you clone a repository, you clone the master and all other branches.
To clone a branch in a git repository, start by cloning the master repository using the git clone command. Once complete, navigate into the repo directory. The command will show the branches that are available in the local repository.
Use the --mirror Option to Clone All Branches in Git Create an empty directory and navigate to it. Clone your repository with the git clone --mirror command. The --mirror option sets up a mirror of the source repository with all branches.
By default, the git clone command duplicates all the branches from a Git repository . To clone only a specific branch, you must use the –single-branch flag with the git commit command.
git branch
only shows local branches by default; use git branch -r
to see remote branches or git branch -a
to see all. git clone
only creates one local branch, master
by default, which tracks (again, by default) the master
branch on the remote repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With