我删除在Rails应用程序我的数据库文件夹与-rGit + Rails:如何恢复使用“git rm -r”删除的文件?
我已经试过
git reset HEAD
和
git reset --hard HEAD
但迁移文件的arent回来的git RM。我尝试了提交,然后运行重置,但仍然没有。
我该怎么办?
我删除在Rails应用程序我的数据库文件夹与-rGit + Rails:如何恢复使用“git rm -r”删除的文件?
我已经试过
git reset HEAD
和
git reset --hard HEAD
但迁移文件的arent回来的git RM。我尝试了提交,然后运行重置,但仍然没有。
我该怎么办?
呦你可以从提交文件中检出它仍然存在的文件。以下是如何做到这一点。
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 reset --hard HEAD^1
(在HEAD之前提交)。或者,您可以使用git log
,然后git reset --hard <hash>
获得之前已知的工作提交的散列。
这好多了。 – 2013-09-30 16:52:18
您可以检出您上次提交或索引中的单个文件。
git checkout db/*
检查了下分贝一切从指数
git checkout master db/*
检查了下分贝一切从主分支
您可能能够挽救大部分的东西,这样的头
阅读更多:git help checkout
请点击这里寻找答案。我相信它涵盖了你的情况。 http://stackoverflow.com/questions/953481/restore-a-deleted-file-in-a-git-repo – 2011-02-17 01:55:06