你如何在gitignore文件中做负向Lookahead / Lookbehind? [英] How do you do negative Lookahead/Lookbehind in the gitignore files?

查看:147
本文介绍了你如何在gitignore文件中做负向Lookahead / Lookbehind?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为一个项目使用git,并希望从路径中排除特定的子文件夹,但不是该文件夹的兄弟文件。例如:

  / Testpath / TestpathA 
/ Testpath / TestpathB
/ Testpath / TestpathC

我想忽略TestpathA和C(以及其他任何可能是这些文件夹的兄弟姐妹的路径,但不是TestpathB



我试过了

  / Testpath / * 
!/ Testpath / TestpathB

但没有用。



我也尝试了
/ Testpath /(?! TestpathB)/ * p>

但那也行不通。

/ p>

  Testpath / * 
!Testpath / TestpathB

编辑:实际上,罢工,你的例子对我来说工作得很好。你究竟做了什么不工作?除了创建 .gitignore ,你是什么命令unning?


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.

解决方案

How about;

Testpath/*
!Testpath/TestpathB

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?

这篇关于你如何在gitignore文件中做负向Lookahead / Lookbehind?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆