A couple of years ago I wrote a small tool called git-third-party — a small zero-dependency alternative to git-submodules and git-subtree
The problem is well known: you need a source level dependency. However, you find a bug in it, which you can't merge into upstream, or you find yourself needing to slightly alter it's behaviour for your needs
I never used this tool, but I feel insecure about forwarding entire codebase into my repo
The only git-modules issue is that you need to fork the repo, pollute your user and all for nothing. And then you need to properly mirror the upstream
Store only the delta. git-third-party keeps just a config and your patches, applied
to a base commit from the remote. That directory is tracked; the actual checked-out working trees are not.
In the end you get a full git experience within that third-party repo
Patches are kept deterministic by stripping metadata like git version and commit hashes, so they don't churn between machines