# Question - .git subdirectories

4 messages from 2019-10-29 to 2019-11-02. Participants: Arkadij Chistyj, brian m. carlson, Jonathan Nieder.
Thread: https://gitlist.dev/t/52151

## Arkadij Chistyj, 2019-10-29 12:26

Subject: Question - .git subdirectories
Message-ID: <CABf25VhaqrbtRTpL5ZNRy59o4JSsiKpF3pk3+54sDCkvzdgAmw@mail.gmail.com>
URL: https://gitlist.dev/e/CABf25VhaqrbtRTpL5ZNRy59o4JSsiKpF3pk3%2B54sDCkvzdgAmw%40mail.gmail.com

```
Hello. I'm not sure it's correctly to write to this email address.
Sorry if it doesn't.
Copy of my home directory stores on external disk under git control. I
have devel/ directory that contains some of my old projects with git
repositories. But main git repository in root of disk is not tracking
and storing their contents. I don't want to use submodules or crutches
such as renaming all .git/ in subdirectories. I just want that git
treats my .git/ subdirs as plain dirs with any other names.
It was already described here:
https://stackoverflow.com/questions/2317652/nested-git-repositories-without-submodules.
It's very simple functionality but I can't find any simple and right solution.
I just want to know is this possible or not? If not possible, then why?
Thank you in advance.

```

## brian m. carlson, 2019-10-31 20:20

Subject: Re: Question - .git subdirectories
Message-ID: <20191031202015.u5l3wzvn64zypnad@camp.crustytoothpaste.net>
URL: https://gitlist.dev/e/20191031202015.u5l3wzvn64zypnad%40camp.crustytoothpaste.net
In-Reply-To: <CABf25VhaqrbtRTpL5ZNRy59o4JSsiKpF3pk3+54sDCkvzdgAmw@mail.gmail.com>

```
On 2019-10-29 at 12:26:23, Arkadij Chistyj wrote:
> Hello. I'm not sure it's correctly to write to this email address.
> Sorry if it doesn't.
> Copy of my home directory stores on external disk under git control. I
> have devel/ directory that contains some of my old projects with git
> repositories. But main git repository in root of disk is not tracking
> and storing their contents. I don't want to use submodules or crutches
> such as renaming all .git/ in subdirectories. I just want that git
> treats my .git/ subdirs as plain dirs with any other names.
> It was already described here:
> https://stackoverflow.com/questions/2317652/nested-git-repositories-without-submodules.
> It's very simple functionality but I can't find any simple and right solution.
> I just want to know is this possible or not? If not possible, then why?

This is not possible.  You can't add a non-bare repository as a part of
a parent repository without using submodules.  Git uses the .git
directory to find the working tree and for safety reasons doesn't allow
files or directories named that to be checked in.  Allowing users to
check in .git directories would allow configuration and hooks to be
stored as part of the repository, which would allow the execution of
arbitrary code if someone cloned it and then changed into the
subrepository.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

```

## Jonathan Nieder, 2019-10-31 23:01

Subject: Re: Question - .git subdirectories
Message-ID: <20191031230106.GB211076@google.com>
URL: https://gitlist.dev/e/20191031230106.GB211076%40google.com
In-Reply-To: <CABf25VhaqrbtRTpL5ZNRy59o4JSsiKpF3pk3+54sDCkvzdgAmw@mail.gmail.com>

```
Hi Arkadij,

Arkadij Chistyj wrote:
>                                               I just want that git
> treats my .git/ subdirs as plain dirs with any other names.
[...]
> It's very simple functionality but I can't find any simple and right solution.
> I just want to know is this possible or not? If not possible, then why?

To add to what brian wrote:

This is one of many things that Git doesn't track:

- empty directories
- full permissions for files it's tracking
- owner, group, other attributes
- resource fork on filesystems that support multiple forks

Git was initially designed to handle source code.  Later, people have
started to use it for tracking other kinds of documents, which has been
nice.  In general, when push comes to shove, the project has prioritized
making it work well for tracking source code and other documents.

Sometimes people find other uses for Git (deployment tool! home
directory tracker! configuration management system!).  It can be
fun[1]. :)  Ultimately, though, it's useful to keep the main goals of
Git in mind.

Sometimes people want to track a Git repository in another repository
as a source of test data for tests they include with their code.  For
this use, using a "git fast-export" stream or other method for
generating a repository at test time can work better, or, if one
really must use a repo-in-repo, using a bare repository.  Brian did a
good job of describing why.

Thanks and hope that helps,
Jonathan

[1] https://public-inbox.org/git/?q=ugfwiini

```

## Arkadij Chistyj, 2019-11-02 19:14

Subject: Re: Question - .git subdirectories
Message-ID: <CABf25Vhkkd19Tz5E=oVAWUh8nn2A5HW-Od62bNX3LR-gC3vSyA@mail.gmail.com>
URL: https://gitlist.dev/e/CABf25Vhkkd19Tz5E%3DoVAWUh8nn2A5HW-Od62bNX3LR-gC3vSyA%40mail.gmail.com
In-Reply-To: <20191031230106.GB211076@google.com>

```
Thanks you very much for the answer! It was very interesting for me
and now I can understand why this doesn't work.
Have a nice weekend.

```
