How do you do negative Lookahead/Lookbehind in the gitignore files?
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
/Te开发者_开发问答stpath/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?
Using
/Testpath/*
!/Testpath/TestpathB
worked for me:
→ cat .gitignore
/Testpath/*
!/Testpath/TestpathB
→ tree
.
└── Testpath
├── TestpathA
│ └── testfile
├── TestpathB
│ └── testfile
└── TestpathC
└── testfile
4 directories, 3 files
→ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .gitignore
# Testpath/
nothing added to commit but untracked files present (use "git add" to track)
→ git add .
→ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: .gitignore
# new file: Testpath/TestpathB/testfile
#
加载中,请稍侯......
精彩评论