`git reset HEAD file`也检出文件吗? [英] Does `git reset HEAD file` also check out the file?

查看:127
本文介绍了`git reset HEAD file`也检出文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我误添加了一个目录到git,当我按照提示这里撤消添加做 git reset HEAD< file> ,我惊讶地发现其中一个文件的当前工作副本有很多变化(工作!), 退回到以前的版本!

I mistakenly added a directory to git and when I followed the tip here to undo the add by doing git reset HEAD <file>, I was horrified to discover that the current working copy of one of the files, which has lots of changes (work!) in it, reverted back to the previous version!

因此,我失去了几个小时的工作... :((

As a result I lost several hours worth of work... :((

我认为只有 git reset HEAD< file> 将它从当前索引中移除

I thought that git reset HEAD <file> only "removes it from the current index without changing anything else. What did I miss?

git reset HEAD< file> 还应从HEAD中检出文件?

如何将未来再次发生类似事件的机会降至最低?

How can I minimize the chances of something like this happening again in the future?

推荐答案

只有 git checkout - < file> 应该恢复之前统计信息中的文件。
git reset HEAD< file> 应该只取消文件的存储空间,不能恢复其内容。

Only git checkout -- <file> should have reverted the files in their previous stats. git reset HEAD <file> should only unstage the file, not revert its content.

这篇关于`git reset HEAD file`也检出文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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