Gitiginore all files except files with .rst extensions?

** 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 it does not change anything.

+3
source share
2 answers

Try the following in .gitignore

*
!*.rst
!*/

This way you tell git not to ignore subdirectories.

+3
source

If you read this SO answer , you will understand how Git to ignore files is system dependent.

gitignoremanpage clearly says that glob will be passed unchanged to the system library functionfnmatch

, Git (Unix Msysgit Windows)?
Windows "**" ( ).

, , *.rst , .gitignore. ( ) , .gitignore (. )

0

Source: https://habr.com/ru/post/1727001/


All Articles