gitgit-loggit-hash

How can I get the hash of a commit immediately before a faulty commit?


A while back there was a commit that pushed some deletes, a few good, a few not so good. It is time to restore the deletes that should not have happend. The following line does come up with a list of all the files that need to be restored:

git show --pretty="" --name-only 9168052f32 | grep -v Mobile-Apps-SDK

The problem I am running into is that hash is when it was deleted. My understanding is that to restore the file that was deleted what is needed is the hash BEFORE the delete.

git log --follow --pretty=format:"%h" -- config/manifest.json 
9168052
11886af
b6b90ab

shows me the list of hashes for one of the files, is there a way to get the second hash, 11886af so that in one long cmd I can restore all the files?


Solution

  • Your 9168052f32 commit will have a parent that you can access using 9168052f32^. That will be the previous commit. If that's the case, you can fish them out from there.