与HEAD不同的文件暂存内容 [英] File Staged Content Different from HEAD

查看:995
本文介绍了与HEAD不同的文件暂存内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用git rm --cached时,出现以下错误:

When I attempt to use git rm --cached I receive the following error:

error: the following file has staged content different from both the file and the HEAD:

我知道我可以使用git rm --cached -f <filename>规避此错误.但是通常,当我使用git rm --cached取消暂存文件时,不会出现此错误.

I know that I can circumvent this error with git rm --cached -f <filename>. But normally when I unstage files with git rm --cached I do not get this error.

我的问题是文件与HEAD具有不同的暂存内容是什么意思.

My question is what does it mean that the file has different staged content from the HEAD.

推荐答案

通常,您对已暂存和修改"的项目获得此状态,即:首先对其进行了修改,然后对其进行了暂存和修改.然后又进行了修改.

Typically, you get this status for an item that is "staged and modified", that is: it was modified in the first place, then it was staged and then it was modified again.

必须谨慎处理此状态,否则如果您现在运行提交,则会导致很多误解,因为将仅提交分段的更改(是的,即使在同一文件上下文中,也将仅提交分段的更改),并且未分阶段的更改将保留在非分阶段区域中,以备将来提交(如果已分阶段).

This status must be handled with care, otherwise lead to a lot of misconception if you now run a commit, since only staged changes will be committed (yes, even in the same file context, only staged changes will be committed), and not staged changes will be kept in the non-staging area for a future commit (if staged).

这篇关于与HEAD不同的文件暂存内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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