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.
Re: Question - .git subdirectories
On 2019-10-29 at 12:26:23, Arkadij Chistyj wrote:
Show 12 quoted lines
> 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
Re: Question - .git subdirectories
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
Re: Question - .git subdirectories
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.