I have a structure like this:
/.gitignore
/submodule/.gitignore
/submodule/file.txt
Inside my submodule the .gitignore
file ignores file.txt
. That is very much logical for the submodule. But in my root I would like to add "file.txt"
to the repo. Is that even possible?
!submodule/file.txt
Adding the line above to /.gitignore
does not work. So for my main repo I would like to overwrite and add it to git but the submodule prevents me from versioning the file.
Nopes, you can't do that. Any file within the submodule can not be added to the master project. It doesn't matter whether it is tracked or not, it just can't be added since the namespace overlaps.
If you really need to do this, then have this file tracked in some other directory (not a submodule) within the master repository, and create a symlink to it in your submodule.
So your structure becomes something like: