Apostol Apostolov

Practical thoughts about software

Importing a simple SVN folder to GitHub

A few days ago I blogged about Why bigger teams need Git/Mercurial. Now I’ll be showing how to import a simple SVN folder to a repository in GitHub.

Disclaimer: The method I’m describing here is the very basic way of importing a normal SVN folder to a GitHub repository. There may be more advanced configurations(if you used branching and tagging) of importing your SVN folder to Git which require different “git svn” command parameters.  You can find more information about the different other options here.

The logical steps of the import are:

  1. Make a users.txt file with all the users that committed to the SVN folder.
  2. Clone the SVN repository to a local folder with “git svn”.
  3. Create a GitHub repository.
  4. Make the GitHub repository a “remote” to the cloned SVN repository.
  5. “Pull” the changes from the GitHub repository locally.
  6. “Push” the local repository with the merged changes and SVN history to GitHub.

We’ll now look at the specifics of each step.

For the import we’ll be needing a text file with a list of the users who contributed – who made the commits in the folder in SVN. The list should have the information for the username in SVN, real name of the person and the email address of the person. It should look like that:

text-file

After that we open a PowerShell in an empty folder and clone the SVN repository with the following command:

git svn clone –-no-metadata –A c:\path\to\users.txt svn://url-to-svn-server/path/to/folder

The command should look similar to this on your screen, given that you change the paths to the SVN and local users.txt file:

clone-command

Then we can open the newly created folder with

cd \local-path\to\repository

After that we must make an GitHub repository. I’ll call the one I’ll be using “Git-SVN-Clone”.  Then via the following command in PowerShell we can make a “remote” to the newly created GitHub repository so we would be able to push the current local repository with its history from SVN to GitHub. We’ll add the “remote” with the name of “server”:

git remote add server https://github.com/asapostolov/Git-SVN-Clone.git

In my case the remote repository url is “https://github.com/asapostolov/Git-SVN-Clone.git” but you can find yours in the page of you repository in GitHub:

github-repository

After we’ve added a remote named “server” we must pull(pull is “fetch and merge”) the remote’s changes(which in our case is the initial commit for creating the repository on the server) to the local folder.

git pull server master

And then we must push the local changes to the server with:

git push --set-upstream server master

And that’s all. We now have a GitHub repository with all the history of SVN commits in it. In just a few lines of commands.

Tags:

Posted By: Apostol Apostolov

Published at

Originally posted at

Comments

No comments posted yet.