HiveBrain v1.2.0
Get Started
← Back to all entries
snippetjavascriptTip

Find lost files using Git

Submitted by: @import:30-seconds-of-code··
0
Viewed 0 times
findgitfileslostusing

Problem

If you've lost files or commits in your Git repository, you can use the git fsck command to find them. This command is useful for recovering lost data or understanding the state of your repository.
Simply running git fsck --lost-found will print a list of all dangling objects (lost files and commits) in your repository. These objects will be extracted into the .git/lost-found directory for further inspection.

Solution

# Syntax: git fsck --lost-found

git fsck --lost-found
# dangling commit 3050fc0de
# dangling blob 807e3fa41
# dangling commit 59ff8481d

Code Snippets

# Syntax: git fsck --lost-found

git fsck --lost-found
# dangling commit 3050fc0de
# dangling blob 807e3fa41
# dangling commit 59ff8481d

Context

From 30-seconds-of-code: find-lost-files

Revisions (0)

No revisions yet.