how to recover deleted file with git - 09-12-23
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
Step 1, find the file:
$ 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:
$ git restore --source fd07ddc3~1 apps/cli/src/db/backfill-search-queue.command.ts
~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