Skip to content

A Python script to help recover lost files following a mistaken 'git reset --hard' command.

License

Notifications You must be signed in to change notification settings

cgddrd/git-reset-head-file-recover

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

git-reset-head-file-recover

A Python script to try recover lost files following a mistaken 'git reset --hard' command.

Disclaimer

This software does not, in any way promise to recover any of your files. It simply provides a mechanism for which to try and recover files yet to be removed by the git garbage collector.

The author takes no responsibility or liability for any damages to files, software or hardware caused as a result of using this software.

Credits

This project is heavily based on an existing Python script provided by user 'Boy' over at StackOverflow.

Usage

  1. Ask Git to list all "unreachable blobs" (i.e. files not added/commit and now unreachable) and pipe this to a file.

     git fsck --cache --unreachable $(git for-each-ref --format="%(objectname)") > <export_filename>
    
  2. Run the Python script.

     python recover_git_blobs.py <export_filename>
    
  3. The script will export a collection of files containing the contents of each cached "unreachable blob". The user can then search through the contents of these files in order to try and find the file they wish to recover.

About

A Python script to help recover lost files following a mistaken 'git reset --hard' command.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages