Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract the source files from a git repository?

Tags:

git

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.

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.

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

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

Let me know if I haven't been clear

like image 629
epurple Avatar asked Jul 10 '14 15:07

epurple


People also ask

How do I export a git repository?

There is no "git export" command, so instead you use the "git archive" command. By default, "git archive" produces its output in a tar format, so all you have to do is pipe that output into gzip or bzip2 or other.

How do I clone a specific folder from a git repository?

In your test repository try creating an additional file at the top level. If you follow your instructions, then you'll also get a copy of that file as well as the directory you want. Remove the 'git sparse-checkout init --cone' but follow all your other instructions, and you'll just get the directory tree you want.


Video Answer


3 Answers

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

Just clone from the bare repository:

git clone project.git

You should end up with a directory called project that has a checkout of the master branch and a .git directory with a clone of the repo. This project directory is a full copy of the repo, but it's the kind you can do useful things with.

like image 78
George Hilliard Avatar answered Oct 05 '22 12:10

George Hilliard


The terminology git uses for this is clone and it means to make a copy of the repository in the current directory.

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.

like image 31
Jorge Bucaran Avatar answered Oct 05 '22 12:10

Jorge Bucaran


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 question or the documentation on how to use it.

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

like image 40
Flo Avatar answered Oct 05 '22 12:10

Flo