git .gitignore:忽略一个特定目录,只忽略那个目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15084780/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 15:36:26  来源:igfitidea点击:

.gitignore: Ignore one specific directory and that one only

gitgitignore

提问by Anders Johansen

I have this directory structure

我有这个目录结构

./bin/<java class files>
./sometool/bin/<files for the tool>

...as well as some other files and directories.

...以及其他一些文件和目录。

It seens that if I want to avoid tracking the java class files, I should add this to the .gitignore file:

它看到如果我想避免跟踪 java 类文件,我应该将它添加到 .gitignore 文件中:

bin/

However, it appears that this also ignores the path ./sometool/bin

但是,这似乎也忽略了路径 ./sometool/bin

Is that correct, and if so, how do I get the behavior I want.

这是正确的,如果是这样,我如何获得我想要的行为。

回答by Romain Sertelon

I think paths in .gitignorehave their root at the project's root, so you may try /bin

我认为路径在.gitignore项目的根目录下有它们的根,所以你可以尝试/bin

EDIT

编辑

And by the way, this is normal behaviour from git.

顺便说一下,这是 git 的正常行为。