如何从 git 存储库中提取源文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24680617/
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-10 18:17:12  来源:igfitidea点击:

How to extract the source files from a git repository?

git

提问by epurple

I am very new to Git, but spent far too much time trying to achieve this. We had a contractor to do it for us a year ago for us, so unless i am missing something, this is doable.

我对 Git 很陌生,但花了太多时间试图实现这一目标。一年前我们有一个承包商为我们做这件事,所以除非我遗漏了什么,否则这是可行的。

We have a git repository (only the project.git and .git directories) this project is a custom website. So we need to extract all the files from the repository to be able to deploy the site.

我们有一个 git 存储库(只有 project.git 和 .git 目录)这个项目是一个自定义网站。所以我们需要从存储库中提取所有文件才能部署站点。

I can see a lot of objects, but obviously nothing which i was expecting (.aspx files etc...)

我可以看到很多对象,但显然没有我所期望的(.aspx 文件等...)

So what is the process to get the files out of the repository?

那么从存储库中获取文件的过程是什么?

Let me know if I haven't been clear

如果我不清楚,请告诉我

回答by George Hilliard

Your contractor left you a bare repository.It is used by Git for remotes that don't have a working copy (for example, on a server).

你的承包商给你留下了一个空仓库它被 Git 用于没有工作副本的远程服务器(例如,在服务器上)。

Just clone from the bare repository:

只需从裸存储库克隆:

git clone project.git

You should end up with a directory called projectthat has a checkout of the masterbranch and a .gitdirectory with a clone of the repo. This projectdirectory is a full copy of the repo, but it's the kind you can do useful things with.

您应该最终得到一个名为的目录,该目录包含分支project的检出master和一个.git包含 repo 克隆的目录。这个project目录是 repo 的完整副本,但它是你可以做有用事情的那种。

回答by Jorge Bucaran

The terminology gituses for this is cloneand it means to make a copy of the repository in the current directory.

git用于此的术语是克隆,它意味着在当前目录中制作存储库的副本。

For example:

例如:

git clone https://github.com/path/to/project 

Optionally you can specify a target directory and put your project there like so

您可以选择指定一个目标目录并将您的项目放在那里

git clone https://github.com/path/to/project path/to/directory

From Git's documentation.

来自 Git 的文档

回答by Flo

Assuming you just want to get all the files out of the repository without creating a new one by cloning, you could just use git archive. See this questionor the documentationon how to use it.

假设您只想从存储库中获取所有文件而不通过克隆创建新文件,您可以使用git archive. 请参阅此问题或有关如何使用它的文档

If you need something other than the masterbranch, you can get a list by using git branch(documentation here).

如果您需要master分支以外的其他东西,您可以使用git branch此处的文档)获取列表。