Git + Rails:如何恢复用"git rm -r"删除的文件?

Chr*_*len 12 git git-rm

我用git rm -r删除了rails应用程序中的db文件夹

我试过了

git reset HEAD
Run Code Online (Sandbox Code Playgroud)

git reset --hard HEAD
Run Code Online (Sandbox Code Playgroud)

但是迁移文件没有回来.我尝试提交,然后运行重置,但仍然没有.

我该怎么办?

hta*_*ata 18

您可以从仍然存在的提交中签出文件.这是怎么做的.

git checkout <commit where the file still exists> -- db
# Example:
git checkout 6936142 -- db

# This also works, but if you have a branch named the same as the file or path,
# it will throw an error.
git checkout 6936142 db
Run Code Online (Sandbox Code Playgroud)