git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Allow adding files from git submodule to parent git repo if they are in .gitignore in the submodule

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 13, 2023, 15:38 UTC
Message-ID
<xmqq34w6nmd8.fsf@gitster.g>
In-Reply-To
<CAL5pyKseyxEfLbgEkDHSqWQVLGkrrcZU=BzRx2zZOaCdQbMaoA@mail.gmail.com>
Alexey Murz Korepov <murznn@gmail.com> writes:
Show 8 quoted lines
> ```
> $ git add -f mysubmodule/config.yaml
> fatal: Pathspec 'mysubmodule/config.yaml' is in submodule 'mysubmodule'
> ```
> But I see no problems with doing this, if the file is in .gitignore of
> the mysubmodule submodule.
>
> So, let's discuss the approach of how we can allow this in git?

What should happen when mysubmodule/.gitignore changes? Who guarantees that such a file stolen by the superproject will stay in the .gitignore file in the submodule?

I do not think you want to go there, and I do not think I want to see such a behaviour in Git, as we would be the ones who will be blamed for the resulting mess.

The right solution probably is to keep such a file in a directory that is separate from the directory where you bind your submodule. Track the file in the superproject, and have a build procedure to copy it into the submodule directory (as an untracked file, of course).

Previous: Alexey Murz Korepov
Message 2 of 2 in “Allow adding files from git submodule to parent git repo if they are in .gitignore in the submodule”
  1. Alexey Murz KorepovDec 13, 2023
  2. Junio C HamanoDec 13, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.