Using local GIT to access remote SVN repository

git is nice. Very nice. But as we are still using SVN for many projects, using git is not always possible. Or, is it?!

Luckily, git comes with very nice support for using it in combination with an SVN remote repository. By doing so, you can clone any SVN remote repository into a local git repository, create local branches, local commits, local reverts, etc… and finally push everything back to SVN.

Creating the initial clone
git svn clone -T trunk -t tags -b branches -A authors.txt {your_SVN_repository_url} {your_local_git_repsoitory_name}.GIT

Example: git svn clone -T trunk -t tags -b branches -A authors.txt http://myserver.com/svn/myrepo/ myrepo.GIT

Note: You need to have an authors.txt file in your local directory from where you execute the command. The file should contain all contributers from the SVN repository. On stackoverflow.com you can find a command to create such a file.

Get latest changes from SVN trunk and pull them into master
git checkout master
git svn rebase

Commit local changes back to SVN
Make sure to apply a git svn rebase first! (See above)

git checkout master
git svn dcommit

Advertisements

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