14

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

Per Lundberg
  • 3,837
  • 1
  • 36
  • 46
epurple
  • 163
  • 1
  • 2
  • 8
  • 4
    simply clone it? `git clone /path/to/project.git` – Memming Jul 10 '14 at 15:34
  • You can look at http://git-scm.com/docs/git-clone – James Black Jul 10 '14 at 15:34
  • Having only the `.git` directory isn't what I would expect either. This is not how you work with git. Someone deleted all the project's files and sent you just the repository control folder. You can try to restore the deleted files by running the command `git reset --hard` one level above the `.git` folder, it should re-create what was deleted based on the commited data. – Havenard Jul 10 '14 at 15:36
  • 1
    @Havenard it might be a bare repo, which makes the most sense for a backup. git clone should fix the issue. – metacubed Jul 10 '14 at 15:48
  • @metacubed (and Havenard) yes indeed. From the solution i have picked from thirtythreeforty, it was a bare repo. Using the CLI instead of the GUI fixed y issue. Thanks all for your help – epurple Jul 11 '14 at 15:29

3 Answers3

24

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.

George Hilliard
  • 15,402
  • 9
  • 58
  • 96
  • This is exactly what I was looking for! I didn't know that we could use clone this way. I initially used the GUI and the clone was not extracting that. Thanks a lot – epurple Jul 10 '14 at 16:07
  • Absolute legend! Saved me 723 hours. – Karl Nov 30 '20 at 13:02
5

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.

Jorge Bucaran
  • 5,588
  • 2
  • 30
  • 48
4

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

Community
  • 1
  • 1
Flo
  • 2,738
  • 1
  • 16
  • 12