Git + Rails: How to restore files deleted with “git rm -r”?

我只是一个虾纸丫 提交于 2019-12-03 02:25:54

You can checkout the file from the commit where it still exists. Here's how to do it.

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

You can checkout individual files from your last commit or index.

git checkout db/* checks out everything under db from the index

git checkout master db/* checks out everything under db from the head of the master branch

you may be able to salvage most of your stuff that way

read more: git help checkout

Try git reset --hard HEAD^1 (the commit just before HEAD). Or you can get the hash of a previous known working commit with git log, then git reset --hard <hash>.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!