I recently migrated my data from one server to another, and decided to convert some old Subversion repositories to Git. Turns out such conversions require more typing than I would like, so I made a simple bash script to automate the process (see below). The script, svn-to-git, takes two parameters:

  1. the source Subversion repository (has to be local)
  2. the destination Git repository (will be created automatically)

Note that the import is rather simplistic and you might want to expand the call to git svn on line 30. The defaults should be enough for the common use cases, however.

Download the script here.

echo "This script converts an SVN repository into a Git repository."
printf "%-15s $1\n" "[source]:" 
printf "%-15s $2\n" "[destination]:"
script_name=`basename "$0"`
if [ ! -e "$src/db" ]
    echo "ERROR: '$1' does not appear to be a Subversion repository." >&2
    exit 1
if [ -e "$dest" ]
    echo "ERROR: '$dest' already exists." >&2
    exit 1
mkdir -p "$dest"
cd "$src"
cd "$cdir"
echo "Cloning repository into $tmp_dir..."
git svn clone --local "file://$abs_src" "$tmp_dir"
echo "$tmp_dir -> $dest"
git clone "$tmp_dir" "$dest"
echo "Cleaning up..."
rm -rf "$tmp_dir"
echo -e "\nDone! You can access your new Git repository at '$dest'."
echo "Good day."

10 responses

Do you want to comment?

Comments RSS and TrackBack Identifier URI ?

Howdy, i read your blog from time to time and i own a similar one and i was
just curious if you get a lot of spam feedback? If so how do you protect against it,
any plugin or anything you can advise? I get so much lately
it’s driving me mad so any assistance is very much appreciated.

April 13, 2013 3:57 am

When I originally left a comment I seem to have clicked on the
-Notify me when new comments are added- checkbox and
from now on each time a comment is added I get 4 emails with the exact same comment.
Perhaps there is a means you are able to remove me from that
service? Thanks!

June 17, 2013 11:25 am

If some one wishes expert view on the topic of blogging and site-building then i recommend
him/her to pay a visit this website, Keep up the nice job.

June 27, 2013 6:34 pm

I do not know whether it’s just me or if everybody else experiencing issues with your website. It appears as though some of the written text within your content are running off the screen. Can someone else please provide feedback and let me know if this is happening to them as well? This could be a issue with my internet browser because I’ve had
this happen previously. Many thanks

July 2, 2013 11:01 am

What’s even better, these can be substituted for your meals.
I actually got so annoyed with doing squats that were not being counted, that I had to end
the workout, and skip into another one. Despite the fact that weight problems has
grown to be not unusual, it’s not healthful.

June 3, 2014 3:22 am

If your skin is not properly moisturize, it will dry and age faster.

Looking beautiful doesn’t have to be hard on your budget or the environment.
We don’t want to end up old and wrinkled because we spent every
other day in a tanning booth.

July 8, 2014 4:32 am

You will have to pay to have the utilities turned
on, buy groceries, stock up on cleaning supplies and re-key the locks.
In house moving services include rearranging
furniture, hanging or repositioning of art or antiques,
clear space for an event or a party or maximising the potential of the home.
Typical of many unsuspecting shoppers, the inquiry suggested they hadn’t taken a realistic inventory of
the scope of services needed to move them, investigated the legitimacy of the advertising service pitching the ‘unbelievably’ low, low price,
or thoroughly vetted the backgrounds of each of the transportation service
providers they were considering surrendering all of their worldly possessions to.

August 4, 2014 1:08 am

HCG does not occur naturally in men, however if used
by men it would maintain a steady level production of testosterone.
These suggestions are provided to assist you in optimizing your meal plans with approved foods
with these quick weight loss diets. This can be easily found online using any major search engine such as Google or Yahoo.

September 23, 2014 12:37 am

There aren’t too many ocean two person sit in fishing kayaks out on the market.

Do not make the mistake of cutting down the tree yourself or hiring a
regular tree removal company to do the job. Techniques Blue crabs are abundant all along the Jersey coast,
in tidal creeks and rivers and in shallow, saltwater bays, from the Hudson River to Delaware Bay.

September 24, 2014 5:32 am

You don’t want to linger until the last minute to make
your plan so I would recommend reading the waterway guidebook
in advance. Many times I have tried to avoid the most popular swims
for this reason because this is where the fish will often feed most carefully and be
most hard to catch. Of course, lots of methods have evolved to try to avoid spooking fish out of
your swim or even stop them from stopping feeding in the possible
case of some line shy fish, and having them leave your swim.

October 2, 2014 9:33 pm

Comment now!