I basically want to find all git repos that have neither a .gitattributes
nor a .gitignore
file at the root.
I used find . -type d '!' -exec test -e "{}/.gitignore" ';' -print
to find it but it lists out all the directories instead of only the top level git directories.
My directory tree looks like this:
GitHub
├─ _Clones
| ├─ repo1 (has .gitignore)
| └─ repo2
├─ _Forks
| ├─ repo1 (has .gitattributes)
| └─ _For-Later
| ├─ repo2
| └─ repo3
├─ myrepo1 (has both)
├─ myrepo2 (has both)
...
└─ myrepo10
In such a layout I would want the output to be _Clones\repo2
, _Forks\_For-Later\repo2
, _Forks\_For-Later\repo3
and myrepo10
.
I've tried using depth
parameter for find but that is a variable for each directory!
.gitignore
and.gitattributes
can appear anywhere within the repository; do you care about that?find
command.