为什么git忽略我更改的文件? [英] Why is git ignoring my changed file?
问题描述
我对git工作目录中的文件进行了任意更改。
git status
无法识别文件已更改。
git add / path / to / file
不起作用。
git add -f / path / to / file
不起作用。
git status / path / to / file
显示文件与'要提交的更改'存储桶一样。
我删除了我的.gitignore文件,只是为了确保。没有改变任何上述行为。
我完成了 git reset --hard
,重做了我的更改。
这里可能会发生什么?
为什么Git会忽略一个文件有两个一般原因: gitignore
和 子模块
。
更具体地说,当<
- 该文件与
$ GIT_DIR / exclude
。 - 该文件与回购库内的
.gitignore
文件中的模式相匹配。 - 该文件匹配特定于用户的
.gitignore
文件中的模式(由<git config --global core.excludesfile <
$ b - The file matches a pattern in
$GIT_DIR/exclude
. - The file matches a pattern in a
.gitignore
file inside the repo. - The file matches a pattern in a user-specific
.gitignore
file (specified by 'git config --global core.excludesfile
'). - The file is part of a submodule.
该文件是子模块的一部分。更多信息可以在另一个SO问题中找到:
I make an arbitrary change to a file within my git working directory.
git status
does not recognized that the file has changed.
git add /path/to/file
has no effect.
git add -f /path/to/file
has no effect.
git status /path/to/file
shows the file as in the 'changes to be committed' bucket.
I removed my .gitignore file, just to be sure. No change to any of the above behaviors.
I have done git reset --hard
, re-made my change. No change to any of the above behaviors.
What could be going on here?
There are two general reasons why Git will ignore a file: gitignore
and submodules
.
To be more specific, the following conditions will cause Git to ignore a file when 'git add
' is invoked:
More info can be found in another SO question:
Unable to track files within Git submodules
这篇关于为什么git忽略我更改的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!