gitignore 目录模式忽略具有相同后缀的文件夹,但我想包含它

发布于 2024-07-24 08:47:30 字数 222 浏览 4 评论 0原文

我有以下目录结构:

src/
out/
cout/
...

并且我想忽略 out/ 但不是 cout/

我尝试过添加 ^out/,但这似乎不起作用。 我也尝试过 out/ 但也忽略了 cout/

有什么建议么?

I have the following directory structure:

src/
out/
cout/
...

and I want to ignore out/ but not cout/.

I've tried putting ^out/, but that doesn't seem to work. I've also tried out/ but that also ignores cout/.

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

东北女汉子 2024-07-31 08:47:30

感叹号(!)应该在匹配之前,不应被忽略。

.gitignore 文件应如下所示:

out/
!cout/

Exclamation mark(!) should precede a match which should not be ignored.

The .gitignore file should look like:

out/
!cout/
故事灯 2024-07-31 08:47:30

对不起各位,我的错误! cout 目录为空,因此未显示在 git status 下。

只需添加 out/ 即可正常工作,并且不会忽略 cout/

多谢!

Sorry guys, my mistake! The cout directory was empty and, therefore, not showing up under git status.

Just adding out/ works fine and doesn't ignore cout/.

Thanks a lot!

风蛊 2024-07-31 08:47:30

你使用的是哪个版本的 git?

使用 msysgit 1.6.3-preview20090507-2,这个简单的

out/

方法对我来说很有效。 cout/ 仍添加到存储库中。

Which version of git are you using?

With msysgit 1.6.3-preview20090507-2, the simple

out/

works for me. cout/ is still added to the repository.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文