忽略git项目上的任何'bin'目录 [英] ignoring any 'bin' directory on a git project
问题描述
.git /
.gitignore
main /
...
工具/
...
...
在main和tools以及任何其他目录中,在任何级别,都可以有一个'bin'目录,我想忽略它(我也想忽略它下面的所有内容)。我已经在.gitignore中尝试了这些模式中的每一个,但它们都不起作用:
/ ** / bin / ** / *
/./**/bin/**/*
./**/bin/**/*
** / bin / ** / *
* / bin / ** / *
bin / ** / *
/ ** / bin / *#以及其他只以*结尾的元素也是
任何人都可以帮我解决问题吗?第一种模式(我认为应该工作的模式)工作得很好,如果我这样做:
/ main / ** / bin / ** / *
但我不想为每个顶级目录,我不想在每次添加新文件时修改.gitignore。
这是在Windows上使用最新的msysgit。
编辑:还有一件事是,在他们的名字中有文件和目录的子字符串'bin',我不希望这些被忽略:)
在版本1.8.2之前, **
.gitignore
中的任何特殊含义。从1.8.2开始,git支持 **
来表示零个或多个子目录(参见版本说明)。
忽略所有名为bin的目录
$ p $ bin /
在 man
页面,这里有一个例子,它使用类似的模式忽略名为 foo
的目录。
编辑:
如果你已经有任何你不想跟踪的git索引中的bin文件夹,那么你需要明确地删除它们。 Git不会停止跟踪已被跟踪的路径,因为它们现在匹配新的 .gitignore
模式。执行文件夹recursivelly( -r )从仅索引( - 缓存)删除( rm )。 root bin文件夹的命令行示例:
git rm -r --cached bin
I have a directory structure like this:
.git/
.gitignore
main/
...
tools/
...
...
Inside main and tools, and any other directory, at any level, there can be a 'bin' directory, which I want to ignore (and I want to ignore everything under it too). I've tried each of these patterns in .gitignore but none of them work:
/**/bin/**/*
/./**/bin/**/*
./**/bin/**/*
**/bin/**/*
*/bin/**/*
bin/**/*
/**/bin/* #and the others with just * at the end too
Can anyone help me out? The first pattern (the one I think should be working) works just fine if I do this:
/main/**/bin/**/*
But I don't want to have an entry for every top-level directory and I don't want to have to modify .gitignore every time I add a new one.
This is on Windows using the latest msysgit.
EDIT: one more thing, there are files and directories that have the substring 'bin' in their names, I don't want those to be ignored :)
Before version 1.8.2, **
didn't have any special meaning in the .gitignore
. As of 1.8.2 git supports **
to mean zero or more sub-directories (see release notes).
The way to ignore all directories called bin anywhere below the current level in a directory tree is with a .gitignore
file with the pattern:
bin/
In the man
page, there an example of ignoring a directory called foo
using an analogous pattern.
Edit:
If you already have any bin folders in your git index which you no longer wish to track then you need to remove them explicitly. Git won't stop tracking paths that are already being tracked just because they now match a new .gitignore
pattern. Execute a folder remove (rm) from index only (--cached) recursivelly (-r). Command line example for root bin folder:
git rm -r --cached bin
这篇关于忽略git项目上的任何'bin'目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!