Git + Rails:如何恢复使用" git rm -r"删除的文件? [英] Git + Rails: How to restore files deleted with "git rm -r"?

查看:172
本文介绍了Git + Rails:如何恢复使用" git rm -r"删除的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  git reset HEAD 

  git reset --hard HEAD 

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



我应该怎么做?

解决方案

您可以从提交中仍然存在的文件中检出文件。

  git checkout<提交文件仍然存在> -  db 
#示例:
git checkout 6936142 - db

#这也可以,但是如果您有一个与文件或路径命名相同的分支,
#它会抛出一个错误。
git checkout 6936142 db


I deleted my db folder in a rails application in with git rm -r

I've tried

git reset HEAD

and

git reset --hard HEAD

but the migration files arent coming back. I tried commiting, then running the reset and still nothing.

What should I do?

解决方案

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

这篇关于Git + Rails:如何恢复使用&quot; git rm -r&quot;删除的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆