Eric Goodwin

.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.

0 comments

Comments

Have your say

A name is required. You may use HTML in your comments.




About

Eric Goodwin is a web developer living in Victoria BC, Canada. You can contact him at eric@ericgoodwin.com

Open Source

Projects

Elsewhere

Archives