What is a good way for git .gitignore to exclude files from keeping directories?

there is a project, mainly directory structure definition, there are multiple layers of nesting, I created a README file in each directory, now I need to exclude all files, only README files (or create .gitkeep under the directory), now there are too many directories, is there a good solution?

such as this (if this doesn"t work, you can look at it as pseudo code):

/Dir/*
!/Dir/README
!/Dir/*/README
Git
May.31,2021

feels that the simple method cannot be implemented, so the suffixes except .md in the directory can only be excluded one by one. If the directory is excluded, the * .md is also excluded.


@ Shuai B Yes, it's troublesome. Now we use the multi-directory hierarchical definition gitignore file to solve the problem. That is, each directory defines a gitignore file, excludes all files in the directory, and then excludes gitignore itself and README files (Note: this scheme requires directories to be nested in the directory, and the parent directory should not have useless files as far as possible).


*
!*/
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ead0-2bc86.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ead0-2bc86.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?