Katipo
Search  
Site Blog
  About  
  Home
About Portfolio Solutions Client Area Contact Us
: : About Us
Awards
Jobs
Our People
What Is A ... ?
Working From Home
News
Photo Gallery
Katipo Blog


Maintaining an SVN repository after moving to Git

We at Katipo recently moved our software Kete to Github. But a few existing clients were still tied to the old SVN repository, so we had to find a way to keep the link between them so we could pull changes from git and commit them back to SVN. Using various sources from the web, we were able to do just that. Here’s how…

Install git-core (which includes git-svn) onto the system you’ll be using.
Clone the existing SVN repository to a temp repository

git-svn clone http://svn.yourdomain.com/yourrepo/trunk ~/svn_to_git

Clone that temp repository to get a clean copy

git clone ~/svn_to_git ~/git_project

cd ~/git_project

Remove the origin remote, so you can add your own.

git remote rm origin

Create a Github account, if you don’t have one yet, and setup your ssh keys (see Github guides for a way to do this). When this in in place, create a new project. When you’re given the settings screen for your new project, copy and execute the line that looks similar to the following

git remote add origin git@github.com:youraccount/yourproject.git

Now push your project to Github

git push origin master

Keep this directory (git_project). You will make changes in it, ‘git add’ them, ‘git commit’ them, ‘git pull’ the latest, and ‘git push’ your changes from here.

When you have made enough changes, and you want to pull them back into SVN, you can do the following. Note we use the Github public protocol this time, and not the ssh protocol. We only need read access from this folder.

cd ~/svn_to_git

git remote add origin git://github.com/youraccount/yourproject.git

git pull origin master

git-svn dcommit -e

-e will take you into an editor where you can erase the default and place in your own describing the changes that will be going in. When you’re finished and want to edit, type

Control + X, Control + S  (save it)
Control + X, Control + C  (close editor)

And that’s about it. If everything goes well, then it should commit up to the SVN repository with your selected commit message.

*Note* In order for this to work flawlessly, no commits, other than dcommit from the svn_to_git folder, must be made to SVN, or you will get merging issues. Any future changes must take place on Github and pulled back.

*Note* Not all of these steps are required once initial setup is complete. Once the above is done, cloning and adding/removing remotes won’t be necessary. All that is required is to make some changes, add/commit/pull/push to github, cd ~/svn_to_git,  git pull origin master, and git-svn dcommit -e

Leave a Reply

You must be logged in to post a comment.


Katipo
Rachel Snowboarding