add the old snippet md files

This commit is contained in:
Travis Shears 2025-06-05 16:20:57 +02:00
parent fc0dd204c7
commit bcf8313a4b
110 changed files with 3048 additions and 0 deletions

View file

@ -0,0 +1,34 @@
---
title: how to recover deleted file with git
seo_description: "short git tutorial on how to recover deleted files with git"
date: 2023-09-12T09:30:17+02:00
draft: false
snippet_types:
- git
---
I'd like to build a new nest.js command based off a file I deleted last week.
Here is how I go about getting that old file back via `git restore`
Step 1, find the file:
```shell
$ git log --name-only
/command
fd8bc2a6 Merge branch 'XXX-1111-remove-search-queue' into 'main'
fd07ddc3 XXX-1111: Remove search queue
apps/cli/src/cli.module.ts
apps/cli/src/db/backfill-search-queue.command.ts
apps/cli/src/db/db.module.ts
...
```
Step 2, restore the file:
```shell
$ git restore --source fd07ddc3~1 apps/cli/src/db/backfill-search-queue.command.ts
```
Note the `~1`. The file in question was deleted in commit fd07ddc3, so to
restore it we need to go one commit before it was deleted. `~1` does exactly
that.