- 模拟場景,先送出檔案至暫存區,
,接着使用指令git add .
,之後通過git reset --hard
檢視暫存區的内容,會出現git status
。如下圖所示:nothing to commit , working tree clean
- 使用指令
find .git/objects/ -type f | xargs ls -lt |sed 6q
- 其中6q表示輸出最近6次的add内容,将我們需要的檔案内容找到,使用
$ git cat-file -p 7479a7c9bb7164b779d9d > a.md
重定向到a.md
檔案,特别注意,需要去掉7479a7c9bb7164b779d9d中的/,之後檢視a.md,即為我們需要的檔案。