如何在 gitignore 文件中执行负 Lookahead/Lookbehind 操作?
我正在将 git 用于项目,并希望从路径中排除特定的子文件夹,但不排除该文件夹的同级文件夹 例如:
/Testpath/TestpathA
/Testpath/TestpathB
/Testpath/TestpathC
我想忽略 TestpathA 和 C (以及可能是这些文件夹的同级文件夹的任何其他路径,但不忽略 TestpathB
我尝试过
/Testpath/*
!/Testpath/TestpathB
但没有成功。
, /Testpath/(?!TestpathB)/*
但这也不起作用。
I am using git for a project and want to exclude a specific subfolder from a path but not the siblings of that folder For example:
/Testpath/TestpathA
/Testpath/TestpathB
/Testpath/TestpathC
I want to ignore TestpathA and C (and any other paths that may be siblings of those folders, but not TestpathB
I tried
/Testpath/*
!/Testpath/TestpathB
but that didn't work.
I also tried
/Testpath/(?!TestpathB)/*
but that didn't work either.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
怎么样;
编辑:实际上,请注意,你的例子对我来说也很好。您到底在做什么但不起作用?除了创建 .gitignore 之外,您还运行哪些命令?
How about;
Edit: Actually, strike that, your example works just fine for me as well. What exactly is it you are doing that isn't working? Besides creating the
.gitignore
, what commands are you running?使用
对我有用:
Using
worked for me: