I am a new user of Git. I have forked a repository called Spoon-Knife (available for practicing forking with Git). Then, I cloned it locally by running
git clone https://github.com/rohinichoudhary/Spoon-Knife.git
This repository contains three branches, i.e.
master,test-branch,change-the-title.
When I run git branch, it only shows *master, not the remaining two branches. And when I run
git checkout test-branch
I get the following error:
error: pathspec 'test-branch' did not match any file(s) known to git.
Why is this happening? How can I solve this problem?
git branchdoesn't listtest_branch, because no such local branch exist in your local repo, yet. When cloning a repo, only one local branch (master, here) is created and checked out in the resulting clone, irrespective of the number of branches that exist in the remote repo that you cloned from. At this stage,test_branchonly exist in your repo as a remote-tracking branch, not as a local branch.You must be using an "old" version of Git. In more recent versions (from v1.7.0-rc0 onwards),
Simply run
instead. Or update to a more recent version of Git.