tags:

views:

103

answers:

2

The ** and * in gitignore are a bit confusing. Here is what I have in .gitignore:

*
!*.rst

This works for all *.rst files in the root directory. What about .rst files in subdirectories?

I tried

*
!*.rst
!**/*.rst

But this does not change anything.

A: 

If you read this SO answer, you will realize the way Git ignore files is system-dependent.

the gitignore manpage clearly says that the glob will be passed un-altered to the system's fnmatch library function

So what OS and Git distro are you using (Unix, or Msysgit on Windows)?
Because on Windows, the '**' does not work very well (if at all).

Plus, make sure your *.rst files were not already added to the cache before you declared them in the .gitignore file. They would need to be removed from the cache (and the purged cache committed) before .gitignore works as intended (see also this blog post)

VonC
I'm on using this on Linux.
MTsoul
+1  A: 

Try the following in your .gitignore

*
!*.rst
!*/

This way you tell git to not ignore subdirectories.

cefstat