git恢复删除后没有提交的删除文件 [英] git recover deleted file where no commit was made after the delete

查看:178
本文介绍了git恢复删除后没有提交的删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我删除了一些文件。



我还没有提交。



我想重置我的工作区以恢复文件。



我做了一个 git checkout。



但是删除的文件仍然没有。



git status 显示:

 #在分支主机上
#要提交的更改:
#(使用git reset HEAD< file> ... )

#已删除:cc.properties
#已删除:store / README
#已删除:store / cc.properties

为什么没有 git checkout 将工作区重置为 HEAD

解决方案

输出告诉你你需要做什么。 git reset HEAD cc.properties 等等。



这会取消rm操作。之后,再次运行 git status 会告诉您需要执行 git checkout - cc.properties 重新获得文件。

更新:
我在配置文件中有这个


  $ git config alias.unstage 
reset HEAD

我通常用它来取消东西。


I deleted some files.

I did NOT commit yet.

I want to reset my workspace to recover the files.

I did a git checkout ..

But the deleted files are still missing.

And git status shows:

# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   deleted:    cc.properties
#   deleted:    store/README
#   deleted:    store/cc.properties
#

Why doesn't git checkout . reset the workspace to HEAD?

解决方案

The output tells you what you need to do. git reset HEAD cc.properties etc.

This will unstage the rm operation. After that, running a git status again will tell you that you need to do a git checkout -- cc.properties to get the file back.

Update: I have this in my config file

$ git config alias.unstage
reset HEAD

which I usually use to unstage stuff.

这篇关于git恢复删除后没有提交的删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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