Git 将“未更改”的文件添加到舞台
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18600639/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git adding "unchanged" files to the stage
提问by user2744374
For a project I'm working on, I want to use:
对于我正在从事的项目,我想使用:
git add . -A
to add some files to the stage. The problem is that Git thinks these files are unchanged from the last commit, so they are ignored. However, I personally changed the file, but Git still sees the file as unchanged.
将一些文件添加到舞台。问题是 Git 认为这些文件自上次提交以来没有改变,所以它们被忽略了。但是,我个人更改了文件,但 Git 仍然认为文件未更改。
How can I "forcefully" add that single file to my repository?
如何“强制”将该单个文件添加到我的存储库中?
回答by inampaki
check your .gitignorefile there must be some pattern matching this file which is excluding file from being staged.
Or you can use git add . -fto forcely add these files.
检查您的.gitignore文件,必须有一些模式与此文件匹配,该模式将文件排除在暂存之外。或者您可以使用git add . -f强制添加这些文件。
回答by functionpointer
It seems like the assume-unchanged-bit is set for that file. With that bit set, git will not look for changes of that file anymore. Unset it by typing:
似乎assume-unchanged为该文件设置了-bit。设置该位后,git 将不再查找该文件的更改。通过键入取消设置:
git update-index --no-assume-unchanged <file>
After that, git statusas well as git addshould detect the changed file.
之后,git status以及git add应该检测更改的文件。

