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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.