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

5
  • 4
    simply clone it? git clone /path/to/project.git
    – Memming
    Commented Jul 10, 2014 at 15:34
  • You can look at git-scm.com/docs/git-clone Commented Jul 10, 2014 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
    Commented Jul 10, 2014 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
    Commented Jul 10, 2014 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
    Commented Jul 11, 2014 at 15:29

3 Answers 3

26

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.

2
  • 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
    Commented Jul 10, 2014 at 16:07
  • Absolute legend! Saved me 723 hours.
    – Karl
    Commented Nov 30, 2020 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.

1
  • Note, you don't have to use a GitHub remote. A bare repository folder works just as well as a source. Commented Jul 10, 2014 at 15:47
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).

Not the answer you're looking for? Browse other questions tagged or ask your own question.