Here is my file folder.
a
├─ b
│ ├─ b1.txt
│ └─ b2.txt
├─ a1.txt
└─ a2.txt
.gitignore
Firstly:
I found if I wanna ignore the folder a, a/
and a/*
and a/**
all can complete.
Secondly:
I wanna ignore all the things in folder a
except the folder b
, the only way to do this is:
a/*
!a/b/
I don't know why a/**
can't do this?
# this way can't except folder b
a/**
!a/b/
Or you can tell me how can I use a/**
?
An asterisk " * " matches anything except a slash. The character " ? " matches any one character except " / ". The range notation, e.g. [a-zA-Z] , can be used to match one of the characters in a range.
We can also put comments in the gitignore file by just putting a # sign in front of any text that we want to be a comment in the gitignore file, maybe we want to provide the reason why we ignored something and any blank lines are simply going to be skipped.
gitignore resides. If the pattern starts with a slash, it matches files and directories only in the repository root. If the pattern doesn't start with a slash, it matches files and directories in any directory or subdirectory.
A trailing asterisk (*) indicates that a DISPLAY command applies to all jobs or started tasks that match a leading character string. The DISPLAY JOBS, J, A, or TS command supports only a trailing asterisk.
**
matches any amount of directories, *
only one.
So if you e. g. ignore /a/**/d/
, then /a/b/d/
and /a/b/c/d/
both are ignored.
If you e. g. ignore /a/*/d/
, then /a/b/d/
is ignored while /a/b/c/d/
is not ignored.
If a folder is ignored, then Git does not even look at its contents to check for inclusions. That is why you cannot ignore /a/
and then include /a/b/
, as Git does not even look into /a/
. Because of this you must instead ignore all contents in /a/
with /a/*
and then include /a/b/
to ignore everything in /a/
, except all contents of /a/b/
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With