Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I pull remote directory first time? [duplicate]

Tags:

git

github

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.

like image 235
Lali Avatar asked Aug 27 '15 09:08

Lali


People also ask

How do I checkout my first remote branch?

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> .

What is the difference between pull and clone?

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.


1 Answers

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
like image 87
Dmitry VS Avatar answered Oct 16 '22 21:10

Dmitry VS