Converting TortoiseSVN Repository into a Git Repository

This article is to help those using TortoiseSVN with transitioning over their repository to Git. One big factor is making sure your commit history transfers over, so you are able to reference it in the future in Git. This tutorial will walk you by step by step by installing Git for Windows, and using Git Bash as the command line to convert the TortoiseSVN repository into a fully functional git clone which can be uploaded to your Github, or Bonobo Git repository with all commit data intact.

Installing Git For Windows

In order to install Git for Windows, you need to download the install application from:

From the front page, you can download the installer to your preferred download location and run the installer.

Set Up and Installation

You’ll be installing Git for Windows using the default settings. Initial set up screen:

Components to be installed:

Please note, on our installation we used Notepad++ as the default editor for git, but feel free to choose your preferred text editor:

During installation, we set up our installation to use Git only from Git Bash. You can choose one of the other two options, but please be aware of the changes they may make to your PATH in Windows:

You can choose to use OpenSSH or PLink as your SSH client during installation:

You can also choose to either to use the OpenSSL Library or the Windows Secure Channel Library. By default, the OpenSSL library is selected:

Configuring the line end conversions. Check out Windows-style, commit Unix-style line endings is set as default:

Choose your default terminal emulator. By default it is MinTTY:

The following are extra options that you can enable/disable if needed:

Once you have gone through the initial setup process, Git for Windows will begin installation and will prompt you when installation is complete:

Once installed, you can run Git Bash which will look like this:

Creating the Users File

When using svn, such as through TortoiseSVN, the users whom have performed changes, or commits, have their name attached to the change. In order for the user info to be converted appropriately to a git user, a users file needs to be created in order to map the svn users to git. Our test svn repository to be used throughout this tutorial is named “Visual Studio”

The format for the users file (which will be named users.txt) is in the following format:

user1 = First Last Name <>

user2 = First Last Name <>

An example of how our users file would look would be as follows:

The name on the left is the name of the user from svn. The name on the right, along with the corresponding email address is the information you want to be mapped to the username from svn to git. Be aware that the svn users are case sensitive, so John and john are two different users. You’ll have to add each variation to your users profile so the users are mapped accordingly. One way to determine what usernames svn uses is by running the following command in the svn repository you plan on converting over to git:

svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > users.txt

In our case, we browsed to the folder containing our svn repository, and right-clicked in the corresponding folder and chose the option “Git Bash Here” as seen below.

This will open the Git Bash command prompt and use the current folder location, in this case the svn repository folder for “Visual Studio”:

With the prompt open, you can enter the command from above, which is:

svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > users.txt

This will create the users.txt file for you in the current folder location in the command prompt:

In your file explorer, you will see the users.txt file that was created, and when opened, you can see the name of the svn users who have made changes:

The following is our result from running the command in our repository. The names in the users file show the people that have committed changes in svn. Be aware your users.txt file may have all users in one line. In our file, we have separated each user into their own separate line for easier reading.

You will need to edit the users.txt file so it contains the email address to each user, so when the users.txt file is used later on, it will map each svn user to a git user. The following demonstrates our updated users file:

As you can see above, when the command was run to gather the users in  svn, it shows Glenn and glenn as two separate users. The user names are case sensitive. Please be aware of this.

Creating Temporary Folder Location for SVN Repository Clone

In order to prepare the svn repository clone, you will create a temp folder which will hold a temporary copy of the svn repository. This folder needs to be created in a different location, due to the fact we have been working in the actual repository folder to create the users file. Using the command line, you can create a directory using a path of your choosing. In our case, this would be in our Documents folder with the temporary folder being named “temp_folder.” The command would be:

mkdir ~/documents/temp_folder

Once you run this command, you will not get a visual confirmation if it completed successfully. One way to determine if the folder was created is by using:

cd ~/documents/temp_folder

This will change the working directory into the directory you just entered. You can also use the cd ~/documents command followed by the ls command, which will display all folders in the directory for the Documents folder.

Initializing Empty Git Repository

Once you’ve ensured your temp folder has been created, you will enter the folder in order to initialize an empty git repository. You will enter the folder by using the previous command:

 cd temp_folder

You will notice that if done successfully, your path will change to the location or folder you entered.

Once inside the temporary folder, you will initialize a git repository and point it towards the location of your svn repository. This can use the svn://, http://, and https// protocols. An example of the command we are to use is git svn init /path/to/repository with /path/to/repository being the address of your repository.

  • Depending on how your svn repository is set up, you may need to use the -s flag, which uses the default settings for trunk, branches and tags.
  • If your repository location/name contains spaces, please make sure to enclose the location with quotation marks. Otherwise, you will get an error.

Mapping Users from SVN to Git using Users.txt File

Now you will point the newly created repository to your users.txt file for it to be able to match svn users to git users appropriately for the cloning process. This will be accomplished using the command:

   git config svn.authorsfile /path/to/users.txt

/path/to/users.txt is the location in which your users.txt file is located which you created earlier.

Using Git SVN Fetch to Download Remote Repository Locally

Once you have pointed git config to your users.txt file, you can proceed to run the command:

git svn fetch

This will download the items from your repository to your temporary folder (in our case temp_folder). Depending on how large your repository is, this may take some time.

  • While git svn fetch is running, it goes through every commit and checks it out accordingly. If it runs and comes across a name that is not in your users.txt file, you may get an error of “Author: John not defined in /path/to/users.txt file” This simply means you did not point to the right users.txt path, or the user is not included in the users.txt file. Users are case sensitive. For example, John and john are two different users. Simply add the user to your users.txt file, save the file, and run git svn fetch. The command will continue from where it left off.

Using Git Clone to Create Clean Git Copy

Once the git svn fetch command is complete, you should go up one level of the temp_folder (assuming you have not changed folders) and create a new folder to contain the clone of the repository. This can be accomplished by using the command:

cd ..

Followed by:

mkdir /path/to/repository/clone


This will create the folder which will contain your git clone. In our scenario, our folder is to be named Visual_Studio_Clone.

Once the above step is done, you can proceed converting your clone into a full git clone by running the command:

git clone temp_folder /path/to/repository/clone

You should get an acknowledgment stating “Cloning into /path/to/repository/clone”… done.” /path/to/repository/clone is the location of the folder which will contain your repository clone.

When the process is complete, you will have a completed git clone with all your commit data from SVN.

Removing Local Remote Origin and Adding Remote Repository Origin

In order for you to be able to use your git clone appropriately and be able to upload it to your repository, you need to remove the origin in the git clone, since currently it will be using the location of the folder from which it created the git svn clone from. You will use the following command in your clone repository folder:

git remote rm origin

Once you remove the origin, you will run the command:

 git remote add origin /path/to/remote/git/repository

/path/to/remote/git/repository will be the address at which your repository is located. This address is needed so you will be able to push your git clone repository to your remote repository. When the command is run, you will not get a confirmation of changes made, but can check by running the command:

git remote -v

This will display the path to your git repository as your origin:

Origin /path/to/remote/git/repository (fetch)

Origin /path/to/remote/git/repository (push)

Uploading Local Git Clone to Remote Repository

After changing your remote origin in the previous step, you are now able to upload your git repository clone with all of your commits from svn to your remote repository. The last step is to upload your clean, working git clone to your repository by using the command:

git push --all

You will see a prompt displaying how many objects are to be uploaded along with the path to your repository. Depending on the size of your repository, the upload may take some time. Once the process is over, you will be able to see your git clone repository successfully uploaded to your remote location, along with all your commit data from SVN. In our case, we uploaded to our local Bonobo Git server, and as an example below,  you can see our repository with all of the commit history from SVN included.