简体   繁体   English

Git Hub:恢复已删除的文件

[英]Git Hub: recover deleted files

当我处于git状态时,我不小心删除了本地计算机上和git shell中的文件,我看到那些文件标记为已删除,如何将这些文件恢复回本地计算机?

如果Git向您显示状态为已删除的文件,则您尚未提交更改,您可以简单地git checkout <name of deleted file>

There is a chance that your IDE automatically stages your changes when you deleted your file. 删除文件时,IDE可能会自动暂存更改。 If this is the case, you will first have to reset that file to your current head before checking out the deleted file. 在这种情况下,您首先必须将该文件重置为当前磁头,然后才能签出已删除的文件。

git reset HEAD path/to/file
git checkout path/to/file

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM