如何告诉 Git 仅忽略存储库顶级中的特定文件名?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6168736/
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
How do I tell Git to ignore a specific filename only in the repository's top level?
提问by PleaseStand
Possible Duplicate:
How to exclude file only from root folder in GIT
可能的重复:
如何仅从 GIT 中的根文件夹中排除文件
For a specific JavaScript project, I am using the TinyWeb HTTP Serverfor local testing (to work around a specific security limitation that applies to file URLs). That program requires I have an index.html
file in the root directory, but I do not want to commit that file to my Git repository.
对于特定的 JavaScript 项目,我使用TinyWeb HTTP Server进行本地测试(以解决适用于文件 URL 的特定安全限制)。该程序要求我index.html
在根目录中有一个文件,但我不想将该文件提交到我的 Git 存储库。
How can I stop Git from bugging me about this "untracked file" on every commit? I do want to commit all index.html
files located in subdirectories.
我怎样才能阻止 Git 在每次提交时就这个“未跟踪的文件”来烦我?我确实想提交index.html
位于子目录中的所有文件。
回答by poke
Add this to your .gitignore
(in the root folder):
将此添加到您的.gitignore
(在根文件夹中):
/index.html
The leading /
makes git use an absolute path (relative to the current .gitignore
location), whereas all other lines are just treated as some kind of wildcard.
前导/
使 git 使用绝对路径(相对于当前.gitignore
位置),而所有其他行都被视为某种通配符。