git 如何第一次拉远程目录?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32246014/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:19:06  来源:igfitidea点击:

How can I pull remote directory first time?

gitgithub

提问by Lali

I am asked to take clone of project repository from GitHub server.

我被要求从 GitHub 服务器克隆项目存储库。

There are three branches on server: master, qaand dev.

服务器上有三个分支:masterqadev

After taking clone to the project, how can I checkout qaor devbranch as both the branches are not on my local machine?

克隆到项目后,由于两个分支都不在我的本地机器上,我如何检出qadev分支?

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.

$ git checkout qa 错误:pathspec 'qa' 与 git 已知的任何文件都不匹配。

回答by Emons

Suppose your project is called SomeProject library and you need branches qaand devbesides default master. Here's what you do:

假设您的项目名为 SomeProject 库,并且您需要分支qadevdefault master。这是你要做的:

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 qaand devtrack corresponding remote branches, and you can check them out:

现在你的本地分支qadev跟踪对应的远程分支,你可以查看它们:

git checkout qa
git checkout dev