Reputation: 42329
I need to create a .gitignore
file that follows these rules:
fil.py
fol/
.pyc
within /fol
I've tried several combinations, but I can't get it to work. Here's what I've tested:
1-
# ignore everything in root
*
# except for this file
!fil.py
# except for this folder
!/fol
# But do ignore these files
/fol/*.pyc
This will track changes made to files within the fol/
folder, but will ignore all new files added to it.
2-
# ignore everything in root
*/
# except for this file
!fil.py
# except for this folder
!/fol
# But do ignore these files
/fol/*.pyc
This correctly tracks both old and new files within fol/
, while ignoring *.pyc
files; but will also track files in the root folder.
3-
# ignore everything in root
/*
# except for this file
!fil.py
# except for this folder
!/fol
# But do ignore these files
/fol/*.pyc
This correctly tracks both old and new files within fol/
, and ignores files in the root folder. But it will also track all *.pyc
files in the fol/
folder.
Any help will be much appreciated.
Upvotes: 0
Views: 194
Reputation: 335
Using the following .gitignore, I believe this is working as you are hoping for.
/*
!fil.py
!/fol
*.pyc
Upvotes: 1