Reputation: 397
I have cloned a Github repository with the "--recursive" qualifier. I then checked out the latest branch in that repository.
Later, the author of the repository added a new branch. When I attempted to checkout that new branch with git checkout branch-name
, git reported that the branch-name
was unknown.
Is there a way to get the new branch-name
without again cloning the repository?
Upvotes: 0
Views: 2459
Reputation: 21
Use git fetch
to retrieve new work done by other people including the newly added branch.
Fetching from a repository grabs all the new remote-tracking branches and tags without merging those changes into your own branches.
If you already have a local repository with a remote URL set up for the desired project, you can grab all the new information by using git fetch remotename
After fetching you can list all the branches including the newly added one by git branch -a
Then, you can select the required branch and checkout by git checkout requiredbranch-name
Upvotes: 2
Reputation: 12829
First fetch from your remote $ git fetch origin
You could list all branches with command git branch -a
And then, checkout required branch.
$ git fetch origin
$ git checkout --track origin/new_branch_1
Upvotes: 0
Reputation: 1915
To get all the data (and also newly added branches) from remote repository which you don't have yet use the command git fetch
.
Upvotes: 3