KansaiRobot
KansaiRobot

Reputation: 9912

Git does not detect a remote branch

I have cloned a repository (from gitlab if relevant) I got the repo in my local machine, the branch being master

I want to checkout to another branch another_target

I can clearly see that this branch exist in the remote repo. However when I do

git checkout another_target 

I got

error: pathspec 'another_target' did not match any file(s) known to git   

Just to check I do

git branch -r

and no! the branch another_target does not appear!

But I can see it in the repo!

Why is this happening and how can I solve it?

Upvotes: 1

Views: 257

Answers (1)

Cory Kramer
Cory Kramer

Reputation: 117856

To update your remote branches you should first run

git fetch

then your checkout should work if the remote branch exists

Upvotes: 3

Related Questions