Track Empty Directories with git
There are times when you'd like to track an empty directory within git but there's a problem: git wont allow you to add a directory that doesn't have a file in it. The easy solution is putting an empty stub file within the directory, and the industry standard for that stub file name is .gitkeep.
You can quickly create the file and commit the "empty" directory from command line:
touch my-empty-dir/.gitkeep
git add my-empty-dir/.gitkeep
git commit -m "Adding my empty directory"
The problem is simple, the solution is easy, but I wanted to highlight that .gitkeep is the industry standard.
![Page Visibility API]()
One event that's always been lacking within the document is a signal for when the user is looking at a given tab, or another tab. When does the user switch off our site to look at something else? When do they come back?
![6 Things You Didn’t Know About Firefox OS]()
Firefox OS is all over the tech news and for good reason: Mozilla's finally given web developers the platform that they need to create apps the way they've been creating them for years -- with CSS, HTML, and JavaScript. Firefox OS has been rapidly improving...
![Create a Simple Slideshow Using MooTools, Part III: Creating a Class]()
![Xbox Live Gamer API]()
My sharpshooter status aside, I've always been surprised upset that Microsoft has never provided an API for the vast amount of information about users, the games they play, and statistics within the games. Namely, I'd like to publicly shame every n00b I've baptized with my...
If you want to keep empty directory in git and be sure that its eventually content won’t be pushed, you have to add line in
.gitignore. Going to the point,.gitkeepis one of the methods and the more common (from my experience) is to create.gitignorewithI’d be interested where the “
.gitkeepis the industry standard” came from. Last time I was looking at a couple of repositories, the preference was an empty.gitignorefile.Good tips, Mathew and David!
@Mathew: When I use this tip, I usually include
*/as well to exclude subfolders. This can be pretty handy for thoselog/,cache, andsessionstypes of directories.