Re: Handling empty directories in Git
- From
Øyvind A. Holm <sunny@sunbase.org>
- Date
- Apr 11, 2014, 12:34 UTC
- Message-ID
- <CAA787rmfWqjkBe0cT4-aXD0uPi-pWhjK0K0g2Vm8V0bJ7TLoMg@mail.gmail.com>
- In-Reply-To
- <1396968442.95061.YahooMailNeo@web120806.mail.ne1.yahoo.com>
On 8 April 2014 16:47, Olivier LE ROY <olivier_le_roy@yahoo.com> wrote:
Show 9 quoted lines
> Hello, > > I have a project under SVN with contains empty directories. > > I would like to move this project on a Git server, still handling empty directories. > > The solution: put a .gitignore file in each empty directory to have them recognized by the Git database cannot work, because some scripts in my projects test the actual emptiness of the directories. > > Is there any expert able to tell me: this cannot be done in Git, or this can be done by the following trick, or why there is no valuable reason to maintain empty directories under version control?
Git doesn't support storage of empty directories, but there are ways around it. As you say, you could place empty files in every directory, but I've never liked this concept. Instead, I use a couple of scripts to store/restore empty directories:
https://gist.github.com/sunny256/419015
This creates a file called ".emptydirs" at the top of the repo, and it can easily be implemented into scripts and build processes.
Greetings, Øyvind