I am working on a project and I created a repository with a master
branch. Someone who is working on it added a branch named new-branch
-- their code changes are in this branch.
However, when I clone the repository:
$ git clone [email protected]:me/my-repo.git
I can clone it successfully, but it only shows the master
branch. I do not know how I can view/get the new-branch
.
How would I pull this branch to my repository?
The classic git clone command with the --single-branch option will clone only the master branch by default. If you want to clone another branch, you should add the --branch flag with the name of the desired branch.
The idea is to use the git-clone to clone the repository. This will automatically fetch all the branches and tags in the cloned repository. To check out the specific branch, you can use the git-checkout command to create a local tracking branch.
If you have a problem cloning a repository, or using it once it has been created, check the following: Ensure that the user has gone through initial GitCentric login and has the correct username, email, and ssh. This should return a usage message that refers to the config-branch, config-repo, and ls-repo commands.
When you clone a repository, all remote branches are created as "remote tracking branches" in your repository. These aren't shown by default, but you can see these with:
git branch -a
If you do a git checkout new-branch
, git will find the remote tracking branch of the same name, automatically create a new local branch from the same commit, and switch to the new local branch.
For future work, the git fetch
command will update all the remote tracking branches with their latest commit from the remote.
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