.gitignore snippet
08/04/25
I found this handy little snippet on github yesterday when I was looking through some of the rails commits.
Git won't add a folder unless there is something in it. If you want to commit an empty folder, the common practice is to add a .gitignore file in the directory.
This snippet will add .gitignore files to all empty directories recursively from your current directory.
~ > find . \( -type d -empty \) -and \( -not -regex ./\.git.* \) -exec touch {}/.gitignore \;
Thanks to Nate for sharing. You can view the commit where he added this snippet in the comments here.
Comments