I have a directory structure like this:
project
├── .gitignore
└── parent
└── file.ts
Gitignore file content:
parent/*
!file.ts
Git does ignore everything under parent but file.ts
which is weird because i did not exclude file.ts
in parent dir in my .gitignore
file.
What might be reason?
In gitignore, entries without a /
mean all files in any directory.
This, file.ts
matches all files named file.ts
in any directories.
If you only want to exclude a file.ts
on the top directory (where the .gitignore
is) then use ./file.ts
.