I noticed my git repository has a lot of .keep
files. They were once useful when their parent directories were otherwise empty, but since then a lot of the directories now have real children that keep them alive in git.
Is there a nice way to remove all unneeded .keep
files? Particularly, those that:
- Have 0 size (no real content)
- Have precisely the name
.keep
- Have neighbors in their folders (i.e. their deletion wouldn't lead to their parent folders becoming empty)
I looked at the docs of git gc
, git clean
, etc. but I didn't find such a feature.
As you can read from Random 'concerns' folders and '.keep' files
.keep
files are just useful files to allow folders to be "committed" to a repository.Here's a command to remove all
.keep
files. Then just commit that as you want afterwards.