无法忽略以前在Git仓库中忽略的文件 [英] Trouble un-ignoring previously ignored files in Git repo
问题描述
我有一个网站有一个 / sites / default / files /
目录,其中通常保留用户内容。考虑到我不需要跟踪这些东西,我将/ sites / default / files /添加到了我的.gitignore文件中。
问题是Git不会停止忽略该目录。我从.gitignore中删除了指定此目录的行,并且它不会跟踪它。我可以选择使用 git add / sites / default / files / -f
来强制git跟踪目录,但我之前已经完成了,看起来很乱。
如果.gitignore不再指定该目录被忽略,为什么我必须强制Git开始跟踪这些文件?
对于后人:我的问题的答案是看得更近。
$ b @twalberg正确指出,在.gitignore文件中可能存在一个我忽略的规则。应用.gitignore规则的级联方式可以更容易地将文件更广泛地排除在预期之外。
据我所知,我对git工作方式的假设是正确的。同样,我的情况似乎并不支持(或反驳)@ J-16 SDiZ对假定 - 不变
位可能发挥的作用的评论。
I have a site that has a /sites/default/files/
directory where user content is typically kept. Figuring that I don't need to be tracking this stuff, I added /sites/default/files/ to my .gitignore file.
Then I discovered that I also wanted to keep some mostly-permanent uploads in that directory as well. Now it makes more sense to track everything in /sites/default/files/ and exclude undesirable subdirectories, instead of doing it the other way around.
The problem is that Git won't stop ignoring that directory. I have removed the lines from .gitignore that specify this directory and it won't track it. I have the option to use git add /sites/default/files/ -f
to force git to track the directory, but I've done that before and it seems messy.
If .gitignore no longer specifies that directory as ignored, why would I have to force Git to start tracking those files?
For posterity: the answer to my problem was "just look closer".
@twalberg pointed out, correctly, that there might be a rule I was overlooking in the .gitignore file. The cascading manner in which the .gitignore rules are applied make it easy to exclude files more broadly than intended.
As far as I can tell, the assumptions I was making about how git works were correct. Similarly, my case doesn't seem to support (or disprove) @J-16 SDiZ 's comments on what role the assume-unchanged
bit may play.
这篇关于无法忽略以前在Git仓库中忽略的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!