* Allow adding files from git submodule to parent git repo if they are in .gitignore in the submodule
@ 2023-12-13 11:07 Alexey Murz Korepov
2023-12-13 15:38 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Alexey Murz Korepov @ 2023-12-13 11:07 UTC (permalink / raw)
To: git
Git submodules are pretty often used to "import" some external git
repository into your git repository, to not manage its files in your
git tree, that's good.
But very often we need to add some file to that submodule and manage
it in our local git repository, and this file is usually in .gitignore
in the submodule's git.
So, the example task is:
Copy a mysubmodule/config.example.yaml to mysubmodule/config.yaml
(which is in .gitignore in the mysubmodule), make local changes, and
store it in the local (parent) root git repo.
But the problem is that we can't add this mysubmodule/config.yaml file
to our root git repository, because receiving an error:
```
$ 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?
Or will be glad to hear and discuss alternatives and workarounds for this task.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Allow adding files from git submodule to parent git repo if they are in .gitignore in the submodule
2023-12-13 11:07 Allow adding files from git submodule to parent git repo if they are in .gitignore in the submodule Alexey Murz Korepov
@ 2023-12-13 15:38 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2023-12-13 15:38 UTC (permalink / raw)
To: Alexey Murz Korepov; +Cc: git
Alexey Murz Korepov <murznn@gmail.com> writes:
> ```
> $ 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).
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-12-13 15:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-13 11:07 Allow adding files from git submodule to parent git repo if they are in .gitignore in the submodule Alexey Murz Korepov
2023-12-13 15:38 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).