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

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

问题描述

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

在分支master上

无需提交,工作目录干净

我正在使用的文件刚刚被修改.

解决方案

我曾遇到一个问题,我曾在我的文件中将 git 索引设置为假设未更改".

您可以告诉 git 停止忽略对文件的更改:

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

如果这对其他奇怪的情况没有帮助,重置可能就足够了.

<小时>

在实践中,我发现删除缓存文件并将其重置为工作:

git rm --cached path/to/filegit 重置路径/到/文件

git rm --cached 表示只从索引中删除文件,reset 告诉 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天全站免登陆