3

I had a problem with my cloud file server and I don't have the source of my project anymore... Is it possible to restore the full project with only the .git folder ?

If it's possible, how can I do it ?

Phoste
  • 1,141
  • 4
  • 18
  • 34
  • 3
    Possible duplicate of [Getting a working copy of a bare repository](https://stackoverflow.com/questions/12450245/getting-a-working-copy-of-a-bare-repository) – Liam Jun 29 '18 at 14:09

1 Answers1

3

Open the Git bash and navigate to the folder containing the .git folder/file. If the prompt shows some branch, then it's looking good for you. You should then be able to just checkout a branch, e.g.

git checkout master

The .git folder should store all the state of that particular local repository.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • Doesn't the OP need to clone the repo? – Liam Jun 29 '18 at 14:10
  • 1
    @Liam If the OP has the ability to `git clone` into some folder, then he doesn't need the `.git` folder in the first place. – Tim Biegeleisen Jun 29 '18 at 14:12
  • Just tested. Seems `checkout` and `clone` essentially both uncompress the repo. You could clone a `.git` folder but this is likely easier TBH – Liam Jun 29 '18 at 14:17
  • @Liam: I'm not sure what you mean by "uncompress the repo". The repository remains unchanged; when you check out a commit, what you are doing is copying the commit's tree content (saved snapshot) into both your *index* (aka *staging-area*, there is a main one for every repository plus one auxiliary one per `git worktree add`-ed work-tree) and your *work-tree*. The files in the work-tree are in ordinary format, so "decompressed" fits well here, but that's for *one commit*, not the entire repo... – torek Jun 29 '18 at 14:52
  • @Liam - In addition to torek's notes, I would point out that the reason `clone` creates a work tree (by default) is because after duplicating the repository, it performs a `checkout` (by default). Either way it's the checkout that's doing the work, so it usually won't make sense to do a clone just for that side-effect. – Mark Adelsberger Jun 29 '18 at 22:07