How to use .gitignore to ignore everything in a directory except one file?
I've found several purported solutions to this problem here on SO, but for some unknown reason none of them work for me.
I need to ignore everything in a given folder except for one particular file. Easy, right? Not so fast.
I've tried most every suggested answer for each of these questions:
- Make .gitignore ignore everything except a few files
- Using .gitignore to ignore everything but specific directories
- Make .gitignore ignore everything except one file
- .gitignore - Ignore everything in a directory except one file
- How to ignore everything in a directory except one file
- gitignore everything except specific files
...but I'm no further along than when I started.
Here's the path to the file to include:
D:\Projects\Website\Website\bin\Settings.json
The repo is at:
D:\Projects\Website
My .gitignore
file was generated by Visual Studio, so it contains this entry:
[Bb]in/
According to many of the answers to the questions above, I should be able to do something like this:
!/Website/[Bb]in/Settings.json
...but that doesn't work. The file is still ignored.
None of these permutations do the trick:
!*/Settings.json
!**/Settings.json
![Bb]in/Settings.json
![Bb]in/**/Settings.json
![Ww]ebsite/[Bb]in/Settings.json
I've also tried putting a separate .gitignore
file in bin
:
# Don't block Settings.json
!Settings.json
!.gitignore
No luck.
How can I block everything in [Bb]in
except for the Settings.json
file?
from Recent Questions - Stack Overflow https://ift.tt/3sRJdSE
https://ift.tt/eA8V8J
Comments
Post a Comment