Memo on how to restore deleted files from git commit logs.
1. Get the hash of the commit that deleted the file
% git rev-list -n 1 HEAD -- spam.js
53599a4616710108d8fd035cf3c303a036a3c59c
2. Restore the target deleted file
% git checkout 53599a4616710108d8fd035cf3c303a036a3c59c^ -- spam.js
The restored file is stored in the staging area.
3. Commit the restored file again
The rest is as usual.
Reference Information
・gitで削除してしまったファイルの復元 - itochin2の日記(仮)
That’s all from the Gemba.