Igor's Blog

I've finally got around to moving the SVN repository that supports all the source code for this blog to Git, specifically GitLab. There were a few hurdles and I came across and many existing articles were useful but didn't quite address my specific case.

I had a SVN repository on my server at home that used a non-standard layout. It didn't have a trunk directory nor did it have branches or tags. The 'trunk' was the repository root itself. After a bit of hacking around I finally converted this repository to Git with all the history intact.

So lets see what I did. In a nutshell what I wanted to do was move the SVN repo over to GitLab. I only cared about the trunk and didn't want the branches or tags to be present in the Git repository (since they didn't exist anyway). In terms of actual URLs, it looked like this:
 SVN to Git
SVN Source: svn:[email protected]:8080/igorkrominnet
Git Target: [email protected]:ikromin/igorkromin.net.git


First thing was to create an author mapping file. Since I knew that I was the only contributor this was easy and I could just create it by hand. The format is svn_user = git_author. It should look something like this, one line per mapping (I only have 1 mapping).
 authors-transform.txt
ikromin = Igor Kromin <[email protected]>


Now was the fun part, the actual migration of SVN data to Git. I did this in a temporary directory, which I'd recommend because you can just wipe it out in case something goes wrong and you have to start all over.
 Migration commands
cd ~/Downloads
mkdir temp
cd temp
git svn clone svn:[email protected]:8080/igorkrominnet --no-metadata -A authors-transform.txt --trunk=. svngit




To explain this, first I change directories to the Downloads folder and create a temp directory and change to that. The 'git svn clone' command is where all the real action is. Here I specify the source SVN repository by its URL. Since this is a one-time migration, I also specify --no-metadata. The author mapping is provided next via the -A flag. The --trunk=. option basically equates to 'use the repository root as the trunk', since I am not using a standard layout this is a critical option to specify. The svngit parameter is just the name of the directory to clone the SVN repo into.

This can take some time, depending on the size of the SVN repository and amount of commits there were to it.

Once the clone was done I wanted to migrate all of the ignore data. However running the following command gave me an error...
 SVN GIT Ignore Error
> git svn show-ignore
config --get svn-remote.svn.fetch :refs/remotes/git-svn$: command returned error: 1


When I looked inside the .git/config file, the fetch was incorrectly set, so I updated it to be 'igorkrominnet:refs/remotes/git-svn' in my case.
 diff .git/config .git/config.bak
...
fetch = igorkrominnet:refs/remotes/git-svn
...


After this I was able to extract the ignore data with the following commands...
 SVN GIT Ignore Data
git svn show-ignore > .gitignore
git add .gitignore
git commit -m 'Convert svn:ignore properties to .gitignore.'



At this point the SVN repository was migrated to Git, but it was still locally on my machine and not in GitLab. To get it to GitLab all I had to do was set a remote origin and push the changes. I already had an empty Git repository created in GitLab prior to this step.
 Git push to remote
git remote add origin [email protected]:ikromin/igorkromin.net.git
git push -u origin master


That was it! At this point I could delete the temp directory I created and clone the Git repository in the location I actually wanted to use it.

All the history was magically there...
gitlabik.png


-i

, , ,
About — I'm an enthusiastic software engineer and consultant interested in many fields including J2EE, programming, electronics, 3D printing, video games, wood working and gardening.
See my Resume for more information.
The views expressed in this blog are my own and not those of my employer.
comments powered by Disqus
My other posts you may like...
Programming, DIY, Games, Hacks, Tech and more.
Follow me on...
Current and Past Projects
See my Resume

Subscribe


RSS Feed

My Other Web Sites

Igor and Elise's Travels
Riverside Expressway Cam
StrFunc() Online
300 George St Blogumentary
Guru JSON-RPC Tester
Extrudifier Object Designer

Recent Blog Posts

New Nintendo 3DS XL, R4i SDHC RTS Lite and DSDoom

Older versions of JD-GUI crashing on macOS Sierra

How does Seeed Fusion stack up as a low budget PCB fab

Where to find the last item (Robbie's lost lyrics) in GravityFalls Lake level

Detecting print requests to print contents of a DIV with JavaScript

Using Google DFP with AdSense on responsive pages

How to change the email subject line in Gmail

Force PHP GD library to load JPEG images that have invalid data

How to uninstall Samsung Smart Switch from your Mac

Facebook adds weather forecasts but forgets to adjust them to your time zone

Recent Galleries

Space Food - Chocolate Ice Cream with Chocolate Chips

Legeod Star Wars AT-DP kit

DIY spare parts computer build with a RAIDMAX Anura case

Fake 'Lepin' brand Lego packaging

Hardwood garden bench with clear resin void filler

Fixing a 3D printer extruder that stopped heating up

Easily increase disk space in a Lenovo Ideapad 100S 14" laptop with an M.2 SSD

Making a multi-piece 3D printed solder spool holder stand

DIY indoor apartment grow light wiring

Good Friday Electronics fun Easter Bunny LED PCB Kit IBEABU-01.0

Top Categories

Blogs I follow

Matt Moores Blog
Georgi's FlatPress Guide
Perplexing Permutations
The Security Sleuth

Friends

RAWS Parts Online
Alpha Dimensions Hosting
Kristensen Photography
Ilia Rogatchevski
Travelling Fairy

Blog Activity

Blog Activity
Follow me on... 
     
...or subscribe for updates!

Don't show this again