添加文件到git的舞台什么也不做,也不能提交 [英] Adding file to git's stage does nothing and cannot be committed

查看:106
本文介绍了添加文件到git的舞台什么也不做,也不能提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经陷入了一个奇怪的境地,在我的一个分支中,一个web.config文件无法添加到舞台上。

  git add path / to / web.config 
git status

与添加文件之前相同。 Web.config似乎需要修改并且尚未添加到舞台。

也许更有趣的是,当我从文件系统中删除Web.config并运行 git status 时,我得到输出这表明我有两个web.config 文件,它们已准备好被删除并且不会暂存。

 #没有为commit提交的变化:
#deleted:path / to / Web.config
#deleted:path / to / web.config

请注意,其中一个具有大写W,另一个具有小写w。我在实际文件系统上删除的文件是一个大写'W'。



编辑1



git ls-files --stage 的输出显示确实有两个文件在索引中按大小写不同。

  100644 63cd5911b9b12bbad559bb69b1b596708b932061 0 path / to / Web.config 
100644 d60ab44bb38f05ffce126ddd3c3293b06e6e4096 0 path / to / web.config

我使用 git cat-file -p< hash>将这些文件输出到一个文件中。 > < file> 并比较这两个文件。虽然文本内容相同,但大写Web.config包含CRLF结尾,小写web.config包含小写结尾。

编辑2



从文件系统中物理删除文件 git reset HEAD 会生成此输出,但文件不在文件系统上恢复,因此不能

 重置
后的非临时更改D path / to / Web.config
D path / to /web.config

我希望工作目录中的文件具有CRLF,因为我在Windows上工作但我想要在内部Git数据库中将文本文件与LF一起存储。所以,我认为这将是63cd591,但我可以在这里基地。



在这种情况下,如何从索引中永久移除path / to / web.config?我在Windows上,不能在我的路径上的文件,只有大小写不同。

解决方案

这个特定问题的最终解决方案是从git缓存中删除两个web.config条目,提交任何更改,然后重新添加所需的Web.config文件回到git。

  git rm --cached path / to / web.config 
git rm --cached path / to / web.config
git commit -m修复confused cache
git add path / to / Web.config
git commit -m添加Web.config


I have gotten myself into a bizarre situation where in one of my branches a web.config file cannot be added to the stage. The output of

git add path/to/web.config
git status

Is the same as as before the file was added. Web.config appears to require modifications and has not been added to the stage.

Perhaps more interestingly, when I delete the Web.config from the file system and run git status I get output that indicates I have two web.config files that are ready to be deleted and are not staged.

# Changes not staged for commit:
#   deleted: path/to/Web.config
#   deleted: path/to/web.config

Note that one has and uppercase W and the other a lowercase w. The file that I removed on the on the actual file system is an uppercase 'W'.

Edit 1

The output of git ls-files --stage shows that there are indeed two files that differ by case in the index.

100644 63cd5911b9b12bbad559bb69b1b596708b932061 0 path/to/Web.config
100644 d60ab44bb38f05ffce126ddd3c3293b06e6e4096 0 path/to/web.config

I output each of these to a file with git cat-file -p <hash> > <file> and compared the two files. While the textual content is the same, the uppercase Web.config contains CRLF endings and the lowercase web.config contains lowercase endings.

Edit 2

With the file physically deleted from the file system git reset HEAD produces this output but the file is not restored on the file system and therefore cannot be added.

Unstaged changes after reset
D    path/to/Web.config
D    path/to/web.config

I want the file in the working directory to have CRLF as I am working on Windows but I would like for text files to be stored with LF in the internal Git database. So, I assume that would be 63cd591 but I could be off base here.

How do I permanently remove path/to/web.config from the index in this scenario? I am on Windows and cannot have to files on my path that differ only by case.

解决方案

The final solution to this particular problem was to remove both web.config entries from the git cache, commit any changes, and re-add the desired Web.config file back to git.

git rm --cached path/to/web.config
git rm --cached path/to/web.config
git commit -m "Repair confused cache"
git add path/to/Web.config
git commit -m "Add Web.config"

这篇关于添加文件到git的舞台什么也不做,也不能提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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