This user hasn't shared any profile information

Posts by admin

HOW TO: Convert An SVN Repository To Git


Following on from last weeks blog post, I’m still going through the process of moving my SVN repos over to Git.  Whilst last weeks method was a straight dump of files and losing all the revision history, this morning I’ve been attempting to actually convert the svn repo so that all the revision history is maintained.

This post provides a step by step guide on how I succeeded in converting an SVN repo to a Git repo. Whilst the requirements and commands worked well for me, if you’re on an OS other than Windows you might need to find your OS equivalents.

My scenario involves converting a remote SVN repo to Git, and then pushing it to a new remote Git repo.


  1. SlikSVN -I used the latest version from here
  2. Git – I used the latest version from here | Alternatives here


  1. If your SVN repo is on your local machine then skip to step #5
  2. The first step was to create a dump of my remote SVN repo.  This was quite straightforward as I use XP-Dev who provide a feature to export repos.  If you don’t have an easy to use interface you can try rsvndump
  3. On your local machine create a new svn repo to load your dump into.  You can use Tortoise SVN, or the following command:
    svnadmin create your-new-repo-name
  4. From this step onwards, make sure you’re using Git Bash and not Command Prompt (unless you’ve got Git configured to work in Command Prompt)
    Use the following command to load your dump file into your new repo:

    svnadmin load your-new-repo-name < your-dump-file.dump
  5. Before you start loading your SVN repo into Git, you’ll need to map your SVN users to into the Git author format.
    To do this just create a new text file called authors.txt and enter all the svn users who’ve accessed that repo in the following format:

    svnusername = Git Username <gitemailaddress>


    ashraf.vali = Ashraf Vali <[email protected]>

    Where ‘ashraf.vali’ is the svn user, and the rest is what my Git credentials will be.

  6. Now that you’ve got everything you need, you can run the Git command which will import your SVN repo into the Git format:
    At this point I would recommend going to #3 of the troubleshooting section below and following the steps to install the svnserve service, but you can try running this command first to see if it works without.

    git svn clone file:///pathto/your-new-repo-name new-git-repo-name –no-metadata -A authors.txt -t tags -b branches -T trunk

You should now have your SVN repo successfully converted into a Git repo.  If you encounter any username errors, just modify your authors.txt file to make sure you include the missing usernames.

Uploading The New Git Repo To A Remote Repo

Now that you’ve got a local Git repo, you can move onto uploading it all to a remote repository

  1.  Move into your newly create Git repo using the cd command:
    cd new-git-repo-name
  2. Set the remote origin of your Git repo to the remote repo URL
    git remote add origin ssh://your-remote-repo-url
  3. Push everything to the remote repo
    git push --all

Everything from your SVN repo should now be in your remote Git repo, including the entire revision history!


Here’s a few problems that you might come across, and their solutions

  1. Initialized empty Git repository in X:/new-git-repo-name/.git/
    E: ‘trunk’ is not a complete URL  and a separate URL is not specifiedTo fix this make sure you put ‘file:///’ before the full path to your SVN repo
    In my case it was:

    git svn clone file:///F:/Websites/Repos/tutelum tutelum-git –no-metadata -A authors.txt -t tags -b branches -T trunk
  2. Initialized empty Git repository in X:/new-git-repo-name/.git/
    Couldn’t open a repository: Unable to open an ra_local session to URL: Unable to open repository ‘file:///X:your-new-repo-name’ at C:\Program Files (x86)\Git/libexec/git-core/git-svn line 1941This will happen if you use backslashes (\) instead of forward slashes (/) in the git svn clone command i.e.

    git svn clone file:///F:\Websites\Repos\tutelum tutelum-git –no-metadata -A authors.txt -t tags -b branches -T trunk

    instead of (correct version):

    git svn clone file:///F:/Websites/Repos/tutelum tutelum-git –no-metadata -A authors.txt -t tags -b branches -T trunk
  3. Couldn’t open a repository: Unable to open an ra_local session to URL: Unable to open repository ‘file:///X:/your-new-repo-name’: Expected FS format ‘2’; found format ‘4’ at C:\Program Files (x86)\Git/libexec/git-core/git-svn line 1941This happens when your SVN repo format is newer than the SVN format included in with Git.  In order to fix it you’ll need to
    install svnserve.exe as a Windows Service.

    To fix first run the following command BUT make sure the filepath to svnserve.exe, and path to the SVN root matches up to your computers’:
    The root should be the path TO, but NOT INCLUDING your-new-repo-name
    Use Command Prompt As An Adminstrator

    sc create svnserve binpath= "\"C:\Program Files\SlikSvn\bin\svnserve.exe\" --service -root F:\Websites\repos --listen-host" displayname= "Subversion Server" depend= tcpip start= auto

    Then start the service using:

    net start svnserve

    Finally, update your git svn clone command to use the SVN server instead of the filepath.  For me this was:

    git svn clone svn://localhost/tutelum tutelum-git –no-metadata -A authors.txt -t tags -b branches -T trunk

Final Words

Whilst I’ve tried to provide as much detail and be as thorough as possible, do bear in mind that I’m fairly new to Git and this was just the easiest way I found of doing it and that I may have done something wrong.  If you do know of a better method or want to suggest improvements to this guide feel free to post in the comments and I’ll update it accordingly.


HOW TO: Enable iPhone Theme On Magento For Mobile Browsers


If you’ve been using Magento as e-commerce platform, then you may have noticed that it comes bundled with an iPhone directory in the app and skin folder.  Until recently I didn’t pay this theme much attention.  However, after experimenting with Magento for a while today I’ve figured out how to automatically display this iPhone theme for anyone with an iPhone, iPod or even an Android browser, and still use your default store theme for everyone else…

  1. Login to your Magento Admin
  2. Go to System -> Configuration from the top menu
  3. Click the Design tab on the left
  4. Click the Themes tab to expand the Themes options
  5. Under Templates click the Add Exception button.  Two new boxes will appear underneath it
  6. In the Matched Expression field enter:
  7. In the Value field enter:
  8. Repeat steps 5-7 for Skin (Images/CSS) and Layout
  9. Click the Save Config button in the top left

That’s it! Your store should now automatically display your mobile theme whenever it detects the iPhone, iPod or Android user-agent.

Don’t forget to update the logos in the iPhone theme to match your stores.

TIP: In step 6 you can enter additional mobile user agents such as Opera, Blackberry etc.

HOW TO: Recursively Delete SVN Folders On Windows


I’ve recently switched to Git after numerous issues with SVN, which I might rant about at some other time…. Since the switch I’ve needed to clean up some SVN checkouts on my computer so that I could move them into a Git repo instead.  It’s really simple to do:

NOTE: Doing this will remove ALL the .svn folders/directories in the SVN checkout you select.

  1. Make a new bat file on your computer.  (Just make a text document and change the extension to .bat)
  2. Open your file in a text editor and paste in the following command:
    FOR /F "tokens=*" %%G IN ('DIR /B /AD /S *.svn*') DO RMDIR /S /Q "%%G"
  3. Save the file
  4. Copy the file to the root of the repository you want to clean
  5. Run the command and wait whilst it goes through and removes all the .svn directories

DOWNLOAD: You can download a copy of my batch file from here

admin's RSS Feed
Go to Top