Using git list-files gives me the directories and the files tracked within. Is there a command like:
git list-directories
or something similar that lists only the tracked non-empty non-recursive directory names?
Using git list-files gives me the directories and the files tracked within. Is there a command like:
git list-directories
or something similar that lists only the tracked non-empty non-recursive directory names?
git ls-files | xargs -n 1 dirname | uniq
git ls-tree -rt HEAD:./ | awk '{if ($2 == "tree") print $4;}'
If the files may contain spaces, we would have to play around with: Using awk to print all columns from the nth to the last which is not very fun.
-r makes it recurse, and -t makes it print trees when recursing, which is turned off by default.
I was unable to use ls-tree as mentioned at: https://stackoverflow.com/a/20247815/895245 because it is hard to deal with directories that have no files, just other directories.
This method also shows empty trees.
Tested on Git 2.19.0.