This can be done by cloning to a new directory, then moving the .git directory into your existing directory.

If your existing directory is named “code”.