This can be done by using the alternates mechanism for git repositories, which allows one git repository to reference the objects stored in another. Note that, as warned in [the manual for git-clone](https://git-scm.com/docs/git-clone)'s notes on --shared, you must take care not to perform operations (such as deleting a branch in the main submodule) that would create unreachable (from branches or HEAD) commits which are still referenced in the worktree (although, since --reference copies some objects, this is much less of a risk).
Git submodule updates allow for a --reference <path> option, just like the one that can be passed to git clone, which will tell git to set up <path> as an alternate source of objects that is checked in preference to the repository URL. This option will only have an effect when cloning, but since this new worktree hasn't cloned these submodules yet, it will take effect.
To check out all submodules by reference, you could use a loop like this. Note that, before doing any cloning, we do a git submodule init so that all the expected metadata is in place.
# In the newly-created worktree - in your example, ../feature
git submodule init
for submodule in $(git config get --file=.gitmodules --all --regexp path); do
git submodule update --reference "../main/$submodule" "$submodule"
done
Note that this doesn't handle recursive submodules - for that, you'll want to repeat this process within each of those sub-repositories.
git worktreeis incompatible with submodules.deinitthe submodules first and delete their confoguration - but it does work)