我用 git rm -r 删除了 rails 应用程序中的 db 文件夹
我试过了
git reset HEAD
和
git reset --hard HEAD
但是迁移文件没有回来。我尝试提交,然后运行重置,但仍然没有。
我该怎么办?
最佳答案
您可以从仍然存在的提交中 checkout 文件。方法如下。
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
关于Git + 轨道 : How to restore files deleted with "git rm -r"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5024288/