Push an individual file from a repo to a new repo and keep command history associated with that file:
git clone <original repo url> temp-repo
cd temp-repo
git remote rm origin
git rm -rf .
git checkout HEAD -- <filename>
git commit -m "<commit message>"
git remote add origin <new repo url> # comments
git pull
git push -fOptional: Add new repo as submodule of original repo
git submodule add <new repo url>
Keep the method but rewrite the history.
If you want/need to keep longer history, you can
--orphanan earlier SHA andcherry-picksubsequent commits from the origin master (before you delete it, of course).