Home > Git, SVN > Working offline with SVN (using Git)

Working offline with SVN (using Git)


Recently, I was faced with a challenge of working offline on a project where the sources were stored in a secured SVN repository. I had no access to this repository from outside the local network. Working on a local copy and committing all the changes together to SVN when I am in the network wasn’t an option for me  (I guess I needn’t detail the dangers of working without versioning systems here). Git was there for my rescue. Here’s how I solved the problem. The approach could also be customized to work with an offline Git repository.

Some definitions used in the article
Source: A development  system within the local network (having access to SVN repository). For example, a Windows PC.
Media: A portable media used to transfer the mirrored repository. For example, a USB stick.
Target: An offline development system not connected to the local network. For example, a Macbook

Setup

1. Follow steps as mentioned in blog post Using GIT as frontend to SVN to setup GIT on Source

2. Change path to Media and create a bare Git repository clone of the Source repository (created with the above step)
git clone –bare <source> <destination>

For example,
git clone –bare C:\Git\project_source project_media

3. Change path to Target and create a clone of the Git repository of Media repository
git clone <source> <destination>

For example,
git clone /Volumes/USB/Git/project_media project_target

Managing repository name (optional)

This step adds a new name for repository on Media as “usb”. This makes pushing/pulling changes to Media easier.

1. Change path to repository on Source and add a new remote repository with
git remote add usb Media>

For example,
git remote add usb D:\Git\project_media

2. Change path to repository on Target and rename the remote repository “origin” to “usb”
git remote ren origin usb

Syncing repositories

Moving changes from Source to Target

1. Commit all changes to SVN

2. Change path to the Git repository on Source and do a sync with SVN using
git svn rebase

3. Push the changes to Media
git push usb master

4. Change path to the Git repository on Target and pull the changes from Media
git pull usb master

Moving changes from Target to Source

1. Change path to the Git repository on Target and commit all changes on Target to Git

For example,
git commit . -m “Fixed from home”

2. Push the changes to Media
git push usb master

3. Change path to the Git repository on Source and pull the changes from Media
git pull usb master

4. Commit all changes made back to SVN
git svn dcommit

Make sure that at no point changes are pulled on to Media or changes pushed from Media. It must be always the other way around

Advertisements
Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: