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.
With CSS border-radius, I showed you how CSS can bridge the gap between design and development by adding rounded corners to elements. CSS gradients are another step in that direction. Now that CSS gradients are supported in Internet Explorer 8+, Firefox, Safari, and Chrome...
CSS and JavaScript: the lines seemingly get blurred by each browser release. They have always done a very different job but in the end they are both front-end technologies so they need do need to work closely. We have our .js files and our .css, but...
Last week I covered a smooth, subtle MooTools effect called Kwicks. Another great MooTools creation is the Accordion, which acts like...wait for it...an accordion! Now I've never been a huge Weird Al fan so this is as close to playing an accordion as...
One thing I love doing is duplicating OS functionalities. One of the things your OS allows you to do easily is move from one item to another. Most of the time you're simply trying to get to the next or the previous item.
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,.gitkeep
is one of the methods and the more common (from my experience) is to create.gitignore
withI’d be interested where the “
.gitkeep
is the industry standard” came from. Last time I was looking at a couple of repositories, the preference was an empty.gitignore
file.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
, andsessions
types of directories.