Another tool exists in Git that can help you find and recover lost commits and even blobs (files), which is
git fsck. The
fsck command tests the object database and verifies the SHA-1 ID of the objects and the connections they make. The command can also be used to find objects that are not reachable from any named reference, as it tests all the objects found in the database, which are under the
Again, we'll use the
hello world repository. If you make a fresh clone, make sure to run the scripts for this chapter (
04_undo_dirty.sh), so there will be some objects for
git fsck to consider. The scripts can be found on the book's homepage. If you just reset the
master branch after performing the other recipes in the chapter, everything is ready.
We can create the fresh clone as follows:
$ git clone https://github.com/dvaske/hello_world_cookbook.git $ cd hello_world_cookbook
We can reset an existing clone as follows:
$ cd hello_world_cookbook...