... and then up to github.com!
On a Mac OS X iBook G4, I had a Subversion repository with a wide variety of projects: my CPAN modules, YAPC and other conference presentations, etc. I wanted to transfer the locus of development for certain projects, beginning with my CPAN distribution List-Compare, to a newer machine running Ubuntu 14.04 Linux. I also wanted to make that development process more publicly available. That meant migrating the projects from Subversion to git, then publishing those projects at https://github.com/jkeenan/.
In git, unlike CVS and Subversion, standard practice is to have one repository per project. That meant that I had to extract one project at a time from the Subversion repository on the Mac and re-store it in a git repository on the Ubuntu. This gist describes that process.
On the basis of some Internet recommendations, I decided to create a dumpfile of the Mac's Subversion repository, then extract the commits for a given individual project into a dumpfile for that project. I would edit that project per Internet recommendations, getting a refined version of that dumpfile. To test the validity of that dumpfile, I would then create a new Subversion repository on the Mac and load it from the dumpfile. I would then do an svn checkout
from that repository and verify the checkout was sound.
The first repository to be transferred was named lc
, standing for List-Compare.
Dump the entire Subversion repository.
svnadmin dump /path/to/repository > ~/repository-dumpfile
Filter the dumpfile to create a project-specific dumpfile.
svndumpfilter include --drop-empty-revs --renumber-revs lc \ < repository-dumpfile \ > lc-dumpfile
Make a gzipped backup as a precaution.
cp -v lc-dumpfile lc-dumpfile.raw gzip -v lc-dumpfile.raw gunzip -c lc-dumpfile.raw.gz > lc-dumpfile
Edit the project-specific dumpfile
vi lc-dumpfile
- 1 Remove the first
Node-path:
block entirely. - 2 Trim
lc
fromNode-path
andNode-copyfrom-path
. -
%s/Node-path: lc\//Node-path: / %s/Node-copyfrom-path: lc\//Node-copyfrom-path: /
- 3 Save file.
Net result should be zero output from:
grep -n 'lc/' lc-dumpfile
- 1 Remove the first
Validate dumpfile.
Before shipping the dumpfile to the second machine, I took the precaution of making sure that I could create a new Subversion repository from its contents.
cd ~ mkdir svn_transfer_repositories cd svn_transfer_repositories svnadmin create lc svnadmin load --ignore-uuid lc < ~/lc-dumpfile
Further precaution: create a new checkout from the new repository.
cd ~ mkdir transfer_checkouts cd transfer_checkouts svn checkout file:///Users/jimk/svn_transfer_repositories/lc/trunk lc cd lc svn log | less
If
svn log
looks okay, we can proceed.Compress per-project dumpfile and send to second machine.
cd ~ gzip -v lc-dumpfile # scp to Linode server
I proceeded on the second machine as cautiously as I had on the first. I verified that I could create a new Subversion repository, populate it with the contents of the dumpfile and do an svn checkout
from that repository. Only then would I proceed with a conversion from Subversion to git.
scp lc-dumpfile.gz from Linode server to ~/Downloads/
Create a new Subversion repository and load it with the dumpfile.
cd ~ mkdir svnrepos cd svnrepos
Anticipating creating a github.com repository named
list-compare
, on the second machine I began to uselist-compare
instead oflc
as the name for a directory or repository.svnadmin create list-compare gunzip -c ~/Downloads/lc-dumpfile.gz | svnadmin load list-compare
Create a location on second machine for svn checkouts
cd mkdir svnwork
Perform an
svn checkout
; verify its validitycd svnwork svn checkout file:///home/jkeenan/svnrepos/list-compare/trunk list-compare cd list-compare svn log |less
Now migrate to git.
Note that
svn2git
by default places files in your current directory. But I wanted a project-specific subdirectory, so I created one.cd ~/gitwork mkdir list-compare cd list-compare svn2git file:///home/jkeenan/svnrepos/list-compare
Confirm validity of git repository
git log
Add a remote
git remote add origin [email protected]:jkeenan/list-compare.git
I went to my account on github.com and used the GUI interface.
I clicked on Create new repository but did not create a README or .gitignore. I already had a README in the distribution and I planned to copy and revise a .gitignore from another project already on the Ubuntu.
I saved the new, empty repository on github.
List-Compare was now stored in its own git repository on my Ubuntu machine. I began by editing by adding a .gitignore and adding ^.git/
to MANIFEST.SKIP to what is now the master branch. I continued by updating the distribution's $VERSION
number, all release and copyright dates, and adding an item to Changes.
vi # edit files as needed
git add .gitignore MANIFEST.SKIP Changes [...]
git rm [...] # as needed
perl Makefile.PL
make
make manifest # then correct MANIFEST as needed
make test
make dist
mv -v List-Compare.0.39.tar.gz ~/localstorage/
# scp tarball to Linode archive
make clean
git push -u origin master
# upload to PAUSE
List-Compare now uses git for source control and is stored on a newer and more powerful laptop.
List-Compare now has a development repository at https://github.com/jkeenan/list-compare.
List-Compare has a new version which has been archived locally and on Linode and released to CPAN.