# Recovering Folder from Git Restored Repo

2 messages from 2016-08-01 to 2016-08-01. Participants: Dennis Putnam, Jeff King.
Thread: https://gitlist.dev/t/42984

## Dennis Putnam, 2016-08-01 20:58

Subject: Recovering Folder from Git Restored Repo
Message-ID: <84080bca-af5f-b957-460a-0a4a81f383e7@bellsouth.net>
URL: https://gitlist.dev/e/84080bca-af5f-b957-460a-0a4a81f383e7%40bellsouth.net

```
I am in a bit of a pickle. I deleted a remote repo that had a folder
that I belatedly realized I need. The deleted repo exists on a backup
which I restored. How do I extract the needed folder from that restored
repo. Not being a git expert I'm not sure what to do but I cannot find
any recognizable sources. This is an 'ls' of the restored repo:

branches  config  description  HEAD  hooks  info  objects  ref

TIA.



```

## Jeff King, 2016-08-01 21:18

Subject: Re: Recovering Folder from Git Restored Repo
Message-ID: <20160801211824.cmjhpvdlohla7cbk@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20160801211824.cmjhpvdlohla7cbk%40sigill.intra.peff.net
In-Reply-To: <84080bca-af5f-b957-460a-0a4a81f383e7@bellsouth.net>

```
On Mon, Aug 01, 2016 at 04:58:47PM -0400, Dennis Putnam wrote:

> I am in a bit of a pickle. I deleted a remote repo that had a folder
> that I belatedly realized I need. The deleted repo exists on a backup
> which I restored. How do I extract the needed folder from that restored
> repo. Not being a git expert I'm not sure what to do but I cannot find
> any recognizable sources. This is an 'ls' of the restored repo:
> 
> branches  config  description  HEAD  hooks  info  objects  ref

That's a "bare" repository, which has no matching working tree, just the
git data. The simplest thing may be to just clone it; the clone will
have a working tree:

  git clone /path/to/restored-repo tmp
  cd tmp

and then you can pick out whatever files you like.

You can also extract the data straight from the bare repository.  Try
"git ls-tree -r HEAD" to see the complete listing of files (replace HEAD
with the name of a specific branch if it was there). You can extract
individual files with "git show HEAD:path/to/file". Or you can generate
a tar or zip archive of a subtree like:

  git archive --format=zip HEAD:my-subdir >foo.zip

-Peff

```
