0

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?

isherwood
  • 46,000
  • 15
  • 100
  • 132
Sam Carleton
  • 1,147
  • 6
  • 21
  • 35
  • Do you mean get it programmatically? Based on what criteria? If this is a one-off thing, just do `git checkout `. – isherwood Jan 13 '20 at 17:30
  • Does this answer your question? [Git: How to find a deleted file in the project commit history?](https://stackoverflow.com/questions/7203515/git-how-to-find-a-deleted-file-in-the-project-commit-history) – phd Jan 13 '20 at 19:21
  • https://stackoverflow.com/search?q=%5Bgit%5D+get+file+previous+commit – phd Jan 13 '20 at 19:21

1 Answers1

1

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.

Noufal Ibrahim
  • 66,768
  • 11
  • 123
  • 160