git you have the "subtree" feature that allows exactly for this.
It will create a new branch with all commits recreated (hence new IDs) to filter out only one directory out of the repository.
Then you can add the repository as a remote, and use only that branch.
You can find a long explanation at https://medium.com/@porteneuve/mastering-git-subtrees-943d29a798ec but note that since this was written things changed in git, now subtree is a core feature.
The complete git documentation for the feature is at https://git.kernel.org/pub/scm/git/git.git/plain/contrib/subtree/git-subtree.txt
The third example is almost exactly what you need:
EXAMPLE 3. Extract a subtree using branch
Suppose you have a source directory with many files and
subdirectories, and you want to extract the lib directory to its own
git project. Here's a short way to do it:
First, make the new repository wherever you want:
$ <go to the new location>
$ git init --bare
Back in your original directory:
$ git subtree split --prefix=lib --annotate="(split)" -b split
Then push the new branch onto the new empty repository:
$ git push <new-repo> split:master
But note that whatever you do, your question is quite odd in git "ideology", so it smells of an XY problem. You should share more details on why do you think you need to do this exactly, because you may just be on a wrong path anyway.