开发者

Gitiginore all files except those with .rst extensions?

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.


Try the following in your .gitignore

*
!*.rst
!*/

This way you tell git to not ignore subdirectories.


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜