Find lost files using Git

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.

# Syntax: git fsck --lost-found

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

More like this

  • Git ·

    Purge a file from Git history

    Did you accidentally commit sensitive information? Learn how to completely purge a file from Git history.

  • Git ·

    View all Git branches

    Learn how to view a list of all local or remote branches in a Git repository.

  • Git ·

    View Git "undo" history

    Learn how to view your "undo" history using git reflog and reset your repository to a previous state.