I tried to follow this article and the various comments left within it, but none of it seemed to work for me. That article naturally assumed that the master branch was being used. I've made some tweaks and came up with my own set of commands to do this that takes branches into account.
Objective: On branch 'dev', move directory 'LibProject1' from Git repository 'source-main' to 'source-utils' while preserving history of commits for that directory.
Assumption: Both source and target repositories have the same branch name set up. This is not a hard requirement and can be tweaked in the commands below but this is what I needed in my case.
Here is the first part, cloning the source repository and extracting just the directory you want to move...
At this point there is a Git repository that's been disconnected from the remote repository and contains just the directory that we're interested in moving.
We don't want to continue working in the source repository directory, so go up a directory...
Now comes the second part, cloning the target repository, creating a remote connection to the source as a branch and pulling in the contents of the branch before finally pushing the changes up to the target remote repository.
That's pretty much it. Now the target repository has the contents and history of the directory you wanted moved over. The original directory can be deleted from the source repository at this stage, also the srcrepo and trgtrepo directories that were created during this process should now be removed as well.