Is it possible to add a sub folder with a .git folder to a repo, without Git treating it like a submodule? I've tried different methods to ignore that .git folder, but nothing this far has worked.
I have tried in /.gitignore:
/vendor/**/.git/
..and in /vendor/.gitignore:
.git/
The .git folder I want to ignore is in /vendor/foo/bar/.
You can use Git excludes for this.
First, create a .gitexclude file:
Then add this file to your Git config as a source of exclusions:
Now you can add files and Git doesn't offer to add them as submodules:
You can verify that a file is indeed "invisible" to Git with
git check-ignore
:Reference: man git-add(1) man git-check-ignore(1)