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 git@github.com: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?
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:
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 fetchcommand will update all the remote tracking branches with their latest commit from the remote.