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).