threads / discuss / 64213

[Feature Request] Support for sharing root-level files across repositories

Subject: [Feature Request] Support for sharing root-level files across repositories

## tl;dr

4 messages between Sep 26, 2025 and Sep 29, 2025.

replies: 3people: 3as markdown or json

George Ogden· Sep 26, 2025, 08:33 UTC · lore
Hello Git developers,

Firstly, apologies if this has already been discussed or if there is a way to solve this problem that I am not aware of.

Motivation

Git submodules are very useful for sharing directories between repositories. However, in some workflows, there is a need to share a single file that must live in the repository root.

A concrete example is .pre-commit-config.yaml. I maintain a standard template across many repositories. When I add a new hook or update a version, I have to manually update the file in each repository. I could use a submodule for this, but submodules always appear in a subdirectory — not at the root where tools expect this file.

The same issue arises with other configuration files that need to reside at the top level of a project (linters, CI configs, licenses, etc.).

Proposal

It would be helpful if Git provided a way to share a file across repositories so that it appears at the root of the working tree, without requiring a separate build step, symlink, or copy operation.

I understand there are alternative approaches (subtrees, packages, external tooling), but they all involve extra indirection. Having first-class support within Git for this use case would make it much simpler and more consistent.

Thanks

Thank you for your work maintaining and evolving Git! I would greatly appreciate any feedback on whether this idea has been considered before, and if there are technical reasons it may not fit Git’s model.

Best regards, George Ogden

rsbecker@nexbridge.com· Sep 29, 2025, 17:25 UTC · re: George Ogden · lore

RE: [Feature Request] Support for sharing root-level files across repositories

On September 26, 2025 4:33 AM, George Ogden wrote:
Show 35 quoted lines
>Hello Git developers,
>
>Firstly, apologies if this has already been discussed or if there is a way to solve this
>problem that I am not aware of.
>
>Motivation
>
>Git submodules are very useful for sharing directories between repositories.
>However, in some workflows, there is a need to share a single file that must live in
>the repository root.
>
>A concrete example is .pre-commit-config.yaml. I maintain a standard template
>across many repositories. When I add a new hook or update a version, I have to
>manually update the file in each repository. I could use a submodule for this, but
>submodules always appear in a subdirectory — not at the root where tools expect
>this file.
>
>The same issue arises with other configuration files that need to reside at the top
>level of a project (linters, CI configs, licenses, etc.).
>
>Proposal
>
>It would be helpful if Git provided a way to share a file across repositories so that it
>appears at the root of the working tree, without requiring a separate build step,
>symlink, or copy operation.
>
>I understand there are alternative approaches (subtrees, packages, external
>tooling), but they all involve extra indirection. Having first-class support within Git
>for this use case would make it much simpler and more consistent.
>
>Thanks
>
>Thank you for your work maintaining and evolving Git! I would greatly appreciate
>any feedback on whether this idea has been considered before, and if there are
>technical reasons it may not fit Git’s model.

I have been thinking about a current use case for this RFE. Consider GNU/Configure-based projects where we have config.guess and config.sub in the repository root. These two files are independent of the project itself and truly should be shared and managed from a single authoritative source. It can be a real delay/pain to wait for the project to manually update these two files from an upstream to get platform support for their project.

In order to support something like this, we might need a submodule concept That supports something like a link upwards. Or this might be something That could be part of the sparse-checkout infrastructure. I'm not sure, but I Do think there is merit to this. It could also apply to organisations that have cross-application root certificates that need to be in the same directory as the application root.

Just my musings. --Randall

George Ogden· Sep 29, 2025, 19:32 UTC · re: rsbecker@nexbridge.com · lore

Re: [Feature Request] Support for sharing root-level files across repositories

Hi Randall,

Thanks so much for your thoughtful reply. I agree that there would be a lot of use cases beyond the one I initially mentioned.

I don’t have the technical background to suggest how this might best fit into Git, but I’d be very interested to hear more from others on the list about possible directions. My main motivation is simply to make it easier to maintain a single shared file across multiple repositories, without having to copy it around manually.

Thanks again for taking the time to engage with this idea. I really appreciate it.

Best regards, George

On Mon, 29 Sept 2025 at 19:25, <rsbecker@nexbridge.com> wrote:
Show 55 quoted lines
>
> On September 26, 2025 4:33 AM, George Ogden wrote:
> >Hello Git developers,
> >
> >Firstly, apologies if this has already been discussed or if there is a way to solve this
> >problem that I am not aware of.
> >
> >Motivation
> >
> >Git submodules are very useful for sharing directories between repositories.
> >However, in some workflows, there is a need to share a single file that must live in
> >the repository root.
> >
> >A concrete example is .pre-commit-config.yaml. I maintain a standard template
> >across many repositories. When I add a new hook or update a version, I have to
> >manually update the file in each repository. I could use a submodule for this, but
> >submodules always appear in a subdirectory — not at the root where tools expect
> >this file.
> >
> >The same issue arises with other configuration files that need to reside at the top
> >level of a project (linters, CI configs, licenses, etc.).
> >
> >Proposal
> >
> >It would be helpful if Git provided a way to share a file across repositories so that it
> >appears at the root of the working tree, without requiring a separate build step,
> >symlink, or copy operation.
> >
> >I understand there are alternative approaches (subtrees, packages, external
> >tooling), but they all involve extra indirection. Having first-class support within Git
> >for this use case would make it much simpler and more consistent.
> >
> >Thanks
> >
> >Thank you for your work maintaining and evolving Git! I would greatly appreciate
> >any feedback on whether this idea has been considered before, and if there are
> >technical reasons it may not fit Git’s model.
>
> I have been thinking about a current use case for this RFE. Consider
> GNU/Configure-based projects where we have config.guess and config.sub in the
> repository root. These two files are independent of the project itself and truly
> should be shared and managed from a single authoritative source. It can be a
> real delay/pain to wait for the project to manually update these two files
> from an upstream to get platform support for their project.
>
> In order to support something like this, we might need a submodule concept
> That supports something like a link upwards. Or this might be something
> That could be part of the sparse-checkout infrastructure. I'm not sure, but I
> Do think there is merit to this. It could also apply to organisations that have
> cross-application root certificates that need to be in the same directory
> as the application root.
>
> Just my musings.
> --Randall
>
Ben Knoble· Sep 29, 2025, 21:17 UTC · re: rsbecker@nexbridge.com · lore

Re: [Feature Request] Support for sharing root-level files across repositories

Show 52 quoted lines
> Le 29 sept. 2025 à 13:25, rsbecker@nexbridge.com a écrit :
> 
> On September 26, 2025 4:33 AM, George Ogden wrote:
>> Hello Git developers,
>> 
>> Firstly, apologies if this has already been discussed or if there is a way to solve this
>> problem that I am not aware of.
>> 
>> Motivation
>> 
>> Git submodules are very useful for sharing directories between repositories.
>> However, in some workflows, there is a need to share a single file that must live in
>> the repository root.
>> 
>> A concrete example is .pre-commit-config.yaml. I maintain a standard template
>> across many repositories. When I add a new hook or update a version, I have to
>> manually update the file in each repository. I could use a submodule for this, but
>> submodules always appear in a subdirectory — not at the root where tools expect
>> this file.
>> 
>> The same issue arises with other configuration files that need to reside at the top
>> level of a project (linters, CI configs, licenses, etc.).
>> 
>> Proposal
>> 
>> It would be helpful if Git provided a way to share a file across repositories so that it
>> appears at the root of the working tree, without requiring a separate build step,
>> symlink, or copy operation.
>> 
>> I understand there are alternative approaches (subtrees, packages, external
>> tooling), but they all involve extra indirection. Having first-class support within Git
>> for this use case would make it much simpler and more consistent.
>> 
>> Thanks
>> 
>> Thank you for your work maintaining and evolving Git! I would greatly appreciate
>> any feedback on whether this idea has been considered before, and if there are
>> technical reasons it may not fit Git’s model.
> 
> I have been thinking about a current use case for this RFE. Consider
> GNU/Configure-based projects where we have config.guess and config.sub in the
> repository root. These two files are independent of the project itself and truly
> should be shared and managed from a single authoritative source. It can be a
> real delay/pain to wait for the project to manually update these two files
> from an upstream to get platform support for their project.
> 
> In order to support something like this, we might need a submodule concept
> That supports something like a link upwards. Or this might be something
> That could be part of the sparse-checkout infrastructure. I'm not sure, but I
> Do think there is merit to this. It could also apply to organisations that have
> cross-application root certificates that need to be in the same directory
> as the application root.
Sparse-checkout made me think of some kind of “repository overlay”: as long as there are no conflicts (or perhaps for later versions, conflicts are resolved by higher-layers-win), each layer (i.e., repository) knows only about its own files.
Adding untracked files would need some work to choose a layer. 

← back to recent threads