Migrate Visual SourceSafe to Git – A short how-to

My hobby/learning projects have been residing in a single-person SourceSafe database for a long time (yes, I know you’re laughing; I don’t care – for single-person projects it’s just fine and dandy.) It was time to start using something new. I wanted to migrate everything, including history, to git.

The first step was to install the latest version of git (Git-1.8.4-preview20130916) on the system that currently hosts the SourceSafe database. If you’re long-term-memory-capacity limited like me and can’t remember git command-line arguments to save your life, you’ll also install something like TortoiseGit while you’re at it. One important step is to choose to run git from the Windows Command line during setup. (The next step needs git in the PATH.)

The second step was to install vss2git (http://code.google.com/p/vss2git/). After some trial-and-error with converting my entire database (a mistake, by the way, see step three) and getting error messages about the log file, I changed the permissions of the install folder to allow “read/write” for every user.

The third step was to convert each main project in SourceSafe (well, via a copy of the SourceSafe folder, actually, just to be paranoid) to a git repository by making sure to use $/Path.to.project in the vss2git tool’s Project field.

image

The fourth step was to convert each of these newly created full repositories to “bare” repositories for sharing across my local network. The command line for that is

git clone –bare –no-hardlinks Path.to.project Path.to.project.git

And that’s pretty much it. A fifth, optional step is to remove the original repository folders that served as the source for the bare repositories (so they don’t clutter up the Windows file share).

I am now the proud “owner” of 13 brand-new, independent little git repositories!

[Update 2013-12-01]

Well, I wasn’t too happy with the above solution. It creates too many nested folders (partly because of how Visual Studio creates stuff in VSS in the first place.) Once I clone the resulting repo, I get something like:

CloneRoot/Uncorked.root/Uncorked.root

That’s not what I want. I need it to be CloneRoot/Uncorked.root at most.

This answer on a StackOverflow question provided a good path to take. Based on that answer, I cobbled together a .cmd file to process all my repositories:

@echo off
for /d %%d in (*) do (
  if not exist %%d\config (
    echo %%d
    cd %%d
    attrib -h .git
    move .git %%d/
    cd %%d/
    attrib +h .git
    git init
    git add .
    git commit -am "moved git root"
    cd ..
    git clone --bare --no-hardlinks %%d %%d.git
    move %%d.git ..
    cd ..
    rem pause
  )
)

1 Comments

  1. Requiring emails is pointless

    A far better solution, which doesn’t result in massive move commits and lost file history, is this:

    git filter-branch –prune-empty –subdirectory-filter YOUR_FOLDER_NAME master

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.