ignoring any 'bin' directory on a git proj

2019-01-01 02:37发布

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 :)

标签: git gitignore
13条回答
伤终究还是伤i
2楼-- · 2019-01-01 03:28

Literally none of the answers actually worked for me; the only one that worked for me was (on Linux):

**/bin
(yes without the / in the end)

git version 2.18.0 
查看更多
登录 后发表回答