Skip to content
Discussion options

You must be logged in to vote

* also ignores abc/ itself. Git cannot re-include abc/xyz.py while its parent directory remains ignored. Use:

*
!*/
!*.py
!.gitignore

!*/ keeps directories traversable, and the slashless !*.py matches Python files at any depth, so !**/*.py is redundant. The final line lets you commit .gitignore itself. Also, git check-ignore -v xyz.py showing a rule beginning with ! means xyz.py is not ignored; the last matching rule wins. I reproduced both results with your original rules using Git for Windows 2.44.0.windows.1, then verified that this replacement leaves root and nested .py files untracked while a nested .txt stays ignored.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Ekopalypse
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants