Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 吉特+;Rails:如何恢复使用“Rails”删除的文件;吉特rm-r";?_Git_Git Rm - Fatal编程技术网

Git 吉特+;Rails:如何恢复使用“Rails”删除的文件;吉特rm-r";?

Git 吉特+;Rails:如何恢复使用“Rails”删除的文件;吉特rm-r";?,git,git-rm,Git,Git Rm,我用git rm-r删除了rails应用程序中的db文件夹 我试过了 git reset HEAD 及 但是迁移文件不会回来了。我试着提交,然后运行重置,但仍然没有结果 我该怎么办?试试git reset--hard HEAD ^1(HEAD前面的commit)。或者,您可以使用git log获取先前已知工作提交的哈希值,然后git reset--hard您可以从上次提交或索引中签出单个文件 git checkout db/*从索引中检出db下的所有内容 git checkout master

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

我试过了

git reset HEAD

但是迁移文件不会回来了。我试着提交,然后运行重置,但仍然没有结果


我该怎么办?

试试
git reset--hard HEAD ^1
(HEAD前面的commit)。或者,您可以使用
git log
获取先前已知工作提交的哈希值,然后
git reset--hard

您可以从上次提交或索引中签出单个文件

git checkout db/*
从索引中检出db下的所有内容

git checkout master db/*
从主分支负责人处签出db下的所有内容

你可以用这种方式打捞你大部分的东西


阅读更多信息:
git-help-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签出--db
#例如:
git签出6936142--db
#这也可以,但是如果您有一个与文件或路径名相同的分支,
#它将抛出一个错误。
git签出6936142 db

在此处查看答案。我相信它涵盖了你的情况。
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