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.
My trip to Mozilla Summit 2013 was incredible. I've spent so much time focusing on my project that I had lost sight of all of the great work Mozillians were putting out. MozSummit provided the perfect reminder of how brilliant my colleagues are and how much...
If you follow me on Twitter, you know that I've been working on a super top secret mobile application using Appcelerator Titanium. The experience has been great: using JavaScript to create easy to write, easy to test, native mobile apps has been fun. My...
Back when I created client websites, one of the many things that frustrated me was the initial design handoff. It would always go like this:
Work hard to incorporate client's ideas, dream up awesome design.
Create said design, using Lorem Ipsum text
Send initial design concept to the client...
One of the sweet effects made easy by JavaScript frameworks like MooTools and jQuery is animation. I ran across this great jQuery tutorial that walks you through animating a background image of a page. Here's a quick MooTools code snippet that...
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.