7

A history

  1. I installed etckeeper
  2. I decided to track e.g. shorewall firewall configuration as its own git repository. I think I wanted it to be easier to look at specific configuration changes. I decided I did not need etckeeper any more and uninstalled it. So no conflict, except...
  3. While re-considering etckeeper, I notice I didn't actually remove /etc/.git.

Before I realized, I would have thought that git init would refuse to create a nested git repository.

If I simply resumed using etckeeper, I'd be concerned that the outer git could get bloated tracking the inner .git directories. Alternatively, it might ignore all the files in the directories which are separate git repositories.

So I'm curious, what could possibly go wrong?

1 Answer 1

8

My first tests with nested git repositories didn't suffer any of those three problems. You don't have to add .git in gitignore; the contents of all .git directories are ignored automatically.

The other files (e.g. in the same directory as .git) can be committed in the outer repository.

So I thought etckeeper could keep tracking all files, while sub-directories could have their history recorded more carefully in specific repositories. The two histories wouldn't know anything about each other.

I only noticed a problem later. When I committed a directory which is a git repository and contains commits itself, and I hadn't already committed files from that directory in the outer repository, then it appears as a Subproject. The contents are represented only by a commit ID. gitk seems to show it as a Submodule instead.

This sounds like git really wants to recognize them as git-submodule. I don't particularly understand git-submodule, I just know it has a reputation for being a bit confusing.

I also noticed the .etckeeper file bloats up with files from the .git directories, even if git is using submodules.

3
  • 4
    I'm sure with SVN such an arrangement is impossible since SVN litters every directory level with .svn directories. That you can do it with git is technically interesting and practically horrifying. +1 for the interesting Q and A. Commented Nov 15, 2016 at 18:52
  • 2
    "Unix will give you enough rope to shoot yourself in the foot. If you didn't think rope would do that, you should have read the man page." Clearly git adheres more closely to the fundamental principles of Unix :).
    – sourcejedi
    Commented Nov 15, 2016 at 20:17
  • 1
    @Doc Svn no longer does that since version 1.7. Commented Nov 15, 2016 at 23:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .