gitignore 规则总是包含具有特定名称的文件夹
gitignore rule to always include folders with a specific name
我的项目根文件夹中有一个根 .gitignore 文件 (Visual Studio)。在某些子文件夹中,我有一个名为 3rdParty 的文件夹,其中包含 lib、debug 和 release 等文件夹,其中包含 dll 文件。
我想将这些提交到我的 GIT 存储库。
在根级别的 .gitignore 中,排除了调试和发布。
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
我试过在没有调试和发布规则的情况下将 .gitignore 文件放在几个 3rdParty 文件夹中。
#[Dd]ebug/
#[Dd]ebugPublic/
#[Rr]elease/
#[Rr]eleases/
但这没有用。有没有办法我可以设置一个!在我的根 .gitignore 中进行规则,以便包含所有级别上名为 3rdParty 的所有文件夹?
规则 !**/3rdParty/** 毕竟可以解决问题。我有上面的规则:
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
当我将规则放在我的 .gitignore 底部时,它起作用了。我从中得到了规则:
https://git-scm.com/docs/gitignore
本节中:
Two consecutive asterisks ("**
") in patterns matched against full pathname may have special meaning:
A leading "**
" followed by a slash means match in all directories. For example, "**/foo
" matches file or directory "foo
" anywhere, the same as pattern "foo
". "**/foo/bar
" matches file or directory "bar
" anywhere that is directly under directory "foo"
.
我的项目根文件夹中有一个根 .gitignore 文件 (Visual Studio)。在某些子文件夹中,我有一个名为 3rdParty 的文件夹,其中包含 lib、debug 和 release 等文件夹,其中包含 dll 文件。
我想将这些提交到我的 GIT 存储库。
在根级别的 .gitignore 中,排除了调试和发布。
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
我试过在没有调试和发布规则的情况下将 .gitignore 文件放在几个 3rdParty 文件夹中。
#[Dd]ebug/
#[Dd]ebugPublic/
#[Rr]elease/
#[Rr]eleases/
但这没有用。有没有办法我可以设置一个!在我的根 .gitignore 中进行规则,以便包含所有级别上名为 3rdParty 的所有文件夹?
规则 !**/3rdParty/** 毕竟可以解决问题。我有上面的规则:
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
当我将规则放在我的 .gitignore 底部时,它起作用了。我从中得到了规则: https://git-scm.com/docs/gitignore
本节中:
Two consecutive asterisks ("
**
") in patterns matched against full pathname may have special meaning:A leading "
**
" followed by a slash means match in all directories. For example, "**/foo
" matches file or directory "foo
" anywhere, the same as pattern "foo
". "**/foo/bar
" matches file or directory "bar
" anywhere that is directly under directory "foo"
.