Converting CVS repo to git repo and export to github

From Wikistix

I have had a few little CVS repositories than I've been steadily migrating to git, and exporting some of those to github. Making notes here so I don't have to keep Googling and reading man pages.

First, create a new local git repository, and import from CVS. Checkout the imported files.

$ mkdir myproj-git
$ cd myproj-git
$ git init
Initialized empty Git repository in /path/to/myproj-git/.git/
$ find /path/to/myproj-cvsroot | cvs-fast-export | git fast-import         
cvs-fast-export: no commitids before 2013-03-13T04:53:53Z.
…
$ git checkout -f

Use the github UI to create a new empty repository. Now create a local bare repository for importing to gihub. This seems to work better with branches & history, etc, but likely isn't required.

$ mkdir /tmp/z
$ cd /tmp/z
$ git clone --bare /path/to/myproj-git
$ cd myproj-git.git
$ git push --mirror https://github.com/USER/REPO.git
$ rm -rf /tmp/z

Finally, you can set the remote URL in the local repository. This can also be used for the initial push, but failed with odd errors when I tried a few times.

$ cd /path/to/myproj-git
$ git remote add origin git@github.com:user/myproj
$ git branch -M main
$ git push -u origin main

See also