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:
- the source Subversion repository (has to be local)
- 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.
#!/bin/bash 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"` src="$1" dest="$2" if [ ! -e "$src/db" ] then echo "ERROR: '$1' does not appear to be a Subversion repository." >&2 exit 1 fi if [ -e "$dest" ] then echo "ERROR: '$dest' already exists." >&2 exit 1 fi mkdir -p "$dest" cdir=`pwd` cd "$src" abs_src=`pwd` cd "$cdir" tmp_dir="/tmp/$script_name-$$" 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." |
11 responses
Do you want to comment?
Comments RSS and TrackBack Identifier URI ?
Trackbacks