This is also known as “mirroring” a repository.
Step by step process
Open your terminal.
Create a bare clone of the repo in your local machine.
git clone --bare https://github.com/username/old-repo-name.git
Notice the
--bare
parameter.Go to the newly cloned directory.
cd old-repo-name
Mirror-push to the new repository[^before doing this make sure that you’ve already created the new repository on GitHub].
git push --mirror https://github.com/username/new-repo-name.git
Remove the local repository created earlier.
cd .. rm -rf old-repo-name