如何包含父 .gitignore 排除的文件夹?
How to include folder excluded by parent .gitignore?
我有两个项目有单独的 .gitignore 文件。
因此,项目结构如下:
child-project-
|
images
.gitignore
main-project-
|
some source code
images-
.gitignore
现在在父级 .gitignore 中有一行 images/
排除了位于父级中名为 images
的目录。但是,我在 child-project
目录中有另一个名为 images
的文件夹,我希望将其包括在内。如何启用它?
要仅忽略顶级目录中的 images/
,请使用
/images/
在最上面.gitignore
。
来自git help ignore
:
A leading slash matches the beginning of the pathname. For example, /*.c
matches
cat-file.c
but not mozilla-sha1/sha1.c
.
使用否定:
目录结构:
.
├ .gitignore
├── child-project
│ ├── .gitignore
│ ├── build
│ │ └── build.zip
│ └── images
│ └── image.png
├── images
│ └── image.ong
└── main-project
根.gitignore:
images
Child .gitignore:
build
!images
现在它将看到 child-project
:
git st
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
child-project/images/
您还可以调整根 .gitignore
以仅排除特定的 images
目录,例如
/images
/path/to/other/project/images
但这需要您列出所有这些目录。
我有两个项目有单独的 .gitignore 文件。
因此,项目结构如下:
child-project-
|
images
.gitignore
main-project-
|
some source code
images-
.gitignore
现在在父级 .gitignore 中有一行 images/
排除了位于父级中名为 images
的目录。但是,我在 child-project
目录中有另一个名为 images
的文件夹,我希望将其包括在内。如何启用它?
要仅忽略顶级目录中的 images/
,请使用
/images/
在最上面.gitignore
。
来自git help ignore
:
A leading slash matches the beginning of the pathname. For example,
/*.c
matchescat-file.c
but notmozilla-sha1/sha1.c
.
使用否定:
目录结构:
.
├ .gitignore
├── child-project
│ ├── .gitignore
│ ├── build
│ │ └── build.zip
│ └── images
│ └── image.png
├── images
│ └── image.ong
└── main-project
根.gitignore:
images
Child .gitignore:
build
!images
现在它将看到 child-project
:
git st
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
child-project/images/
您还可以调整根 .gitignore
以仅排除特定的 images
目录,例如
/images
/path/to/other/project/images
但这需要您列出所有这些目录。