https://davidwalsh.name/git-empty-directory
https://medium.com/@kinduff/hey-git-please-keep-those-folders-eb0ed37621c8

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:

# ignore files in folder foo
foo/*
# but keep the folder by keeping .gitkeep file
!foo/.gitkeep


touch foo/.gitkeep #add .gitkeep file

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

'DevOps > Git' 카테고리의 다른 글

git-diff(1) Manual Page  (0) 2020.01.10
git commit 규약  (0) 2019.09.26
gitignore bestpractice  (0) 2019.09.05
git stash커맨드에 대해 알아보자  (0) 2019.08.23
git reflog  (0) 2019.07.24

+ Recent posts