从 Git 恢复文件?
该问题与问题“如何恢复发生致命文件系统错误后的 Git?”,但对于单个文件。
我需要到达最后状态 2009-07-27 23:58,我需要该文件:
/Users/henri/BAckup/6-relationdiagram/Normalized_perhaps_DB/simple_schema0.tcuml
如何我在崩溃后恢复文件?
添加:我在哪里可以找到该文件? 他们应该做什么?
格雷厄姆的提示
$git checkout 63c6844fded9cfcdee14c9330be82557046b3e56 HENRI_suunnittelu_doc/6-relaatiotietokantakaavio/Normalized_perhaps_DB/simple_schema0.tcuml
威廉的提示
git checkout bee6763b55cf8259438aa575cedbb09d1d02b96a HENRI_suunnittelu_doc/6-relaatiotietokantakaavio/Normalized_perhaps_DB/simple_schema0.tcuml
The question is related to the question "How to restore Git after fatal file system error?", but for a single file.
I need to get to last state 2009-07-27 23:58, where I need the file:
/Users/henri/BAckup/6-relationdiagram/Normalized_perhaps_DB/simple_schema0.tcuml
How can I restore the file after a crash?
ADDED: Where will I find the file? What are they supposed to do?
Graham's tip
$git checkout 63c6844fded9cfcdee14c9330be82557046b3e56 HENRI_suunnittelu_doc/6-relaatiotietokantakaavio/Normalized_perhaps_DB/simple_schema0.tcuml
William's tip
git checkout bee6763b55cf8259438aa575cedbb09d1d02b96a HENRI_suunnittelu_doc/6-relaatiotietokantakaavio/Normalized_perhaps_DB/simple_schema0.tcuml
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您需要从存储库中的提交中获取单个文件,那么 git checkout 将为您完成。 具体来说:
将检索文件来自提交到您当前的工作副本中。 可以是对任何提交的任何引用,因此它可以是分支名称、标签名称、HEAD^^^^ 或您想要的任何类似名称...
If you need to get a single file out of a commit that is in your repository then git checkout will do it for you. Specifically:
will retrieve the file <filename> from the commit <sha> into your current working copy. can be any reference to any commit, so it could be a branch name, a tag name, HEAD^^^^, or anything at all like that that you want...
有时我删除 git local 中的文件或目录,并且我想恢复该文件。 我运行以下命令:
注意之间的空格。
sometimes i delete a file or directory in my git local and i want to restore just that file. i run the following command:
note the spaces in between.
您在任何地方都有未损坏的存储库副本吗? 如果是这样,请从那里拉到您的工作目录,然后签出该文件。 您可以执行以下操作:
获取所需的哈希值,然后通过以下方式获取文件:
如果您没有存储库的未损坏的工作副本,您可以尝试“git fsck”,但如果文件丢失,成功的机会很小或为零。
Do you have an uncorrupted copy of the repository anywhere? If so, pull from there to your working directory and then checkout the file. You can do:
to get the hash you want and then get the file via:
If you have no uncorrupted working copies of the repository, you might try 'git fsck', but your chance of success is small or zero if files have been lost.