Using git for SVN repos

Posted on Sat 21 March 2015 in tech

We're forced to use SVN for some projects at the university. It's OK but when working on the go (Train) and offline it's a pain. Here are the steps for using git.

# initialize repo
git svn clone https://svn-server-address/repo/path

Now you can work and commit to your local git branches.

git checkout -b myFeature
# do some stuff
git commit -m "whatever"

To publish my new feature to svn I use the following steps:

# fetch the latest svn updates to my master branch
git checkout master
git svn rebase

# rebase my new feature to master
git checkout myFeature 
git rebase master

# merge my feature and force git to always make a merge commit
git checkout master
git merge myFeature --no-ff

# commit changes to svn
git svn dcommit

Yes, its dcommit and not commit.