Recursively add .gitignore files to empty dirs

  • Download Gist
Recursively add .gitignore files to empty dirs
1 2 3 4 5 6
# Recursively add a .gitignore file to all directories
# in the working directory which are empty and don't
# start with a dot. Helpful for tracking empty dirs
# in a git repository.
 
for i in $(find . -type d -regex ``./[^.].*'' -empty); do touch $i"/.gitignore"; done;

find . ( -type d -empty ) -and ( -not -regex './.git.*' ) -exec touch {}/.gitignore \;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.