git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Handling empty directories in Git

From
OROlivier LE ROY <olivier_le_roy@yahoo.com>
Date
Apr 8, 2014, 18:06 UTC
Message-ID
<1396980369.49724.YahooMailNeo@web120801.mail.ne1.yahoo.com>
In-Reply-To
<vpqob0blpna.fsf@anie.imag.fr>
Hi Mattieu,
thanks for this answer. It is clear enough.
Olivier LE ROY

----- Mail original ----- De : Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> À : Olivier LE ROY <olivier_le_roy@yahoo.com> Cc : "git@vger.kernel.org" <git@vger.kernel.org> Envoyé le : Mardi 8 avril 2014 17h03 Objet : Re: Handling empty directories in Git

Olivier LE ROY <olivier_le_roy@yahoo.com> writes:
> 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.

Another option is to have a post-checkout hook that does the mkdir for you. Or do that in the build system if your use case is to store untracked generated files in the directory.

> Is there any expert able to tell me: this cannot be done in Git, or
> this can be done by the following trick,
https://git.wiki.kernel.org/index.php/Git_FAQ#Can_I_add_empty_directories.3F
Short answer: it cannot be done.
> or why there is no valuable reason to maintain empty directories under
> version control?

The reason would be closer to "there is a valuable reason, but not valuable enough to change Git to do it". It's actually not so easy to track directories properly. Storing them in the Git repository is actually possible (actually, an empty tree is a special case of this, and is obviously supported), but defining and implementing a decent behavior for each Git command wrt this is not trivial.

David Kastrup gave it a try a few years ago. I don't remember exactly what made him give up, but it was never completed and merged.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Olivier LE ROYNext: Øyvind A. Holm
Message 8 of 9 in “Handling empty directories in Git”
  1. Olivier LE ROYApr 8, 2014
  2. Andrew KellerApr 8, 2014
  3. Andrew KellerApr 8, 2014
  4. Olivier LE ROYApr 8, 2014
  5. Matthieu MoyApr 8, 2014
  6. David KastrupApr 8, 2014
  7. Olivier LE ROYApr 8, 2014
  8. Olivier LE ROYApr 8, 2014
  9. Øyvind A. HolmApr 11, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.