I am asked to take clone of project repository from GitHub server.
There are three branches on server: master
, qa
and dev
.
After taking clone to the project, how can I checkout qa
or dev
branch as both the branches are not on my local machine?
I tried the command
git checkout qa
it raised an error
$ git checkout qa error: pathspec 'qa' did not match any file(s) known to git.
If you want to check out a remote branch someone published, you first have to use git fetch . This command downloads the references from your remote repository to your local machine, including the reference to the remote branch. Now all you need to do is use git checkout <remote branch name> .
git pull is a (clone(download) + merge) operation and mostly used when you are working as teamwork. In other words, when you want the recent changes in that project, you can pull. The clone will setup additional remote-tracking branches.
Suppose your project is called SomeProject library and you need branches qa
and dev
besides default master
. Here's what you do:
git clone https://github.com/someperson/someproject.git
cd someproject
git checkout -b qa origin/qa
gir checkout -b dev origin/dev
Now your local branches qa
and dev
track corresponding remote branches, and you can check them out:
git checkout qa
git checkout dev
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