忽略git中同名文件夹但不忽略文件。

17

我的代码结构是:

.gitignore
my-service << this is a file without an extention
charts
| my-service << this is a folder
| | file1
| | file2

当我在我的 gitignore 文件中写入 my-service 时,它会忽略文件和文件夹 my-service

如何只忽略根目录下的文件,而不是子目录?


也许这个链接会有用: https://www.2brightsparks.com/bb/viewtopic.php?t=10067 - Rann Lifshitz
1个回答

33

你可以在 .gitignore 中使用 ! 来实现相反的效果。

myservice
!myservice/

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接