I've been using Subversion for years and it's high time to switch to Git. So I finally got moving on that last night, starting with various non-site projects like my contributed Drupal modules.
So far:
- Set up an account at GitHub (I've been hosting my own SVN repo and don't want to bother with that anymore; besides, GitHub offers so much more than code repositories.)
- Install Git for Mac package.
- Install SVN2Git.
- On my server, backup my SVN repo with
tar (in case I lose some critical files or file history in the process).
My projects are all in subdirectories of one SVN repo, but in Git they're supposed to be separate. For each project in SVN:
- Create a repo in Github
- Create a holder for the new repository locally:
mkdir PROJECT
- Initialize a repository in that directory:
git init
- Import from SVN:
svn2git https://path/to/svn/dir --rootistrunk
- Connect the local repo to the Github repo:
git remote add origin git@github.com:USERNAME/PROJECT.git
- Push/sync it:
git push origin master
In some cases I was pulling the SVN directories via svn:externals into other sites. So as a stopgap, I switched the external URL to GitHub's read-only SVN access, and it moved over seamlessly.
SVN2Git imports the entire history of the files, including trunk/tags/branches if applicable (in this case the --rootistrunk flag indicates a flat structure), so I could then delete the files from my SVN repo.
Next steps:
* Read Pro Git (free) and other Git resources I've collected.
* Learn how to establish a Git-centric development/Drupal workflow.
* Start moving whole sites from SVN to Git.
For anyone interested, the code for my Drupal modules and other code I'll release publicly over time will live at http://github.com/newleafdigital. (Unfortunately for now, contributed Drupal modules still have to be copied to CVS, but that's moving to Git eventually as well.)