Repo structure:
.gitignore
file1
file2
dir/
file3
<stuff>
I want to ignore everything inside dir except file 3. Here's what I have in my .gitignore file:
dir/*
!dir/file3
But this doesn't seem to work. git still tries to index everything in dir. How do I fix this?
UPDATE - Fixed after deleting the old .gitignore file, and making a new one. The new one was not made using > .gitignore.
The right way to do it is:
!dir
dir/*
!dir/file3
Note that there are other solutions, such as creating a local .gitignore file in dir/, which will take precedence over the previous one.
Curiously, I also tried your solution, and
dir/*
!dir/file3
Seems to work for me. If someone could comment on this, it would be appreciated.
this worked for me:
!/dir/
/dir/*
!/dir/file3
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