Reputation: 1481
I have the following .gitignore file:
# Ignore everything
*
# But not these
!.gitignore
!Code
!Materials
The intention is to ignore everything except the .gitignore file itself, and everything under the Code and Materials directories. Somehow when I open SourceTree, the .gitignore file is properly excluded, but the Code and Materials directories are ignored. What did I do wrong?
Upvotes: 1
Views: 80
Reputation: 224859
*
matches every file in those directories as well (and Git doesn’t keep track of empty directories). You can ignore just the top level:
# Ignore everything
/*
# But not these
!/.gitignore
!/Code
!/Materials
Paths like /Code/example.cs
won’t be matched by /*
, because *
can only represent one path component, but a simple *
without the /
will match the example.cs
component of /Code/example.cs
.
Upvotes: 3