为什么git不能识别我的文件已被更改,因此git add不起作用 [英] Why doesn't git recognize that my file has been changed, therefore git add not working

查看:1161
本文介绍了为什么git不能识别我的文件已被更改,因此git add不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用bash将我的文件推送到github。他们已经在那里,我正在上传带有新行和代码的新版本,但是当我尝试 git add ,然后 git status 它说:


关于分支主人



没有提交,工作目录干净


并且我正在使用的文件刚刚被修改。

解决方案

我曾经有一个问题,我曾经在我的文件中将git索引设置为'假定不变'。



pre $ g $ update-index --no-assume-不变的路径/至/文件

如果这对重置可能已经足够用于其他奇怪的情况。






在实践中,我发现删除了缓存文件并重新设置了它:

  git rm  - 缓存路径/至/文件
git重设路径/至/文件
$ b

git rm --cached 表示只从索引中删除文件,重置告诉git重新加载上次提交的git索引。


I am trying to push my files to github using bash. They are already on there, and I am uploading a newer version with new lines and code, etc. But when I try git add and then git status it says:

On branch master

nothing to commit, working directory clean

And the file I am using was just modified.

解决方案

I had a problem where once upon a time I set the git index to 'assume unchanged' on my file.

You can tell git to stop ignoring changes to the file with:

git update-index --no-assume-unchanged path/to/file

If that doesn't help a reset may be enough for other weird cases.


In practice I found removing the cached file and resetting it to work:

git rm --cached path/to/file
git reset path/to/file

The git rm --cached means to only remove the file from the index, and reset tells git to reload the git index from the last commit.

这篇关于为什么git不能识别我的文件已被更改,因此git add不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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