2

A colleague of mine attempted to delete the contents of a subdirectory from a Git repository. She pushed the local commit to the remote master (on a self-hosted GitLab repository). Now whenever we clone the remote repository, the subdirectory still gets cloned, but is empty. How is this even possible? I thought that Git works only with files, not with directories, and that it's not possible for a repository to contain an empty directory.

Some sanity checks I've run:

  • The subdirectory in question really is empty (i.e., it doesn't contain any hidden files).
  • The subdirectory really is a directory (i.e., it isn't as symbolic link).
  • The subdirectory isn't for a submodule. (The Git project has no submodules.)

What other circumstances could possibly lead to Git maintaining an empty directory? Is there something else I am overlooking, or is this a new feature (or possibly a bug) in Git?

Psychonaut
  • 859
  • 8
  • 22
  • One possibility is the method described in [this answer](https://stackoverflow.com/a/8944077/1256452). Note that if any submodules get added, the magic directory magically changes into a submodule (!). – torek Aug 03 '17 at 18:48
  • @torek I doubt that's the answer. The colleague is a Git newbie and probably wouldn't have gone through such an arcane process. – Psychonaut Aug 04 '17 at 18:55
  • Well, at this point I think one would need more info to debug this, e.g., the repository itself, the specific Git version you are using, and the host OS and perhaps file system type, in case it has something to do with case-sensitivity. – torek Aug 04 '17 at 18:56
  • I'm using Git 2.12.3 on openSUSE Leap 42.2 with a Btrfs file system. I can't share the repository as it contains private information. (Though if there is some way of anonymizing it by replacing the file contents and filenames with placeholders, I could make it available for inspection.) – Psychonaut Aug 05 '17 at 16:28
  • OK, btrfs should at least not be case-folding by default, which rules out some possible problems. 2.12.3 might have some unknown bug(s), but of course I don't know of any. :-) I'm afraid it's nearly impossible to do the "replace file contents and file names with placeholders" trick, as tree hashes depend on both, and commit hashes depend on tree hashes. – torek Aug 05 '17 at 16:41

0 Answers0