Thursday, September 19, 2013

Simple Git SVN

I'm a huge fan of Git. I use it at home, at work; just about anytime I want to keep an easy history of things I'll break out a simple 'git init .' and be on my way to Git nirvana. Unfortunately, not all development organizations use Git. But alas, there's still hope! If you happen to find yourself in a group that uses Subversion, never fear, git-svn is here. Here's a breakdown of my basic workflow.

Initializing a New Local Git Repo From Subversion


Method 1 - not using the svn standard /trunk /branches /tags off of project root


  1. git svn init /path/to/your/project/root
  2. git svn fetch

Method 2 - using the svn standard /trunk /branches /tags off of project root


  1. git svn init /path/to/your/project/root -s
  2. git svn fetch

During the init, you might notice a message about "using higher level of URL." This is normal.


Submitting an Existing Git Repo Into Subversion


Method 1 - not using the svn standard dir structure

  1. svn mkdir --parents /path/to/your/project/root/
  2. git svn init /path/to/your/project/root
  3. git svn fetch
  4. git rebase trunk

Method 2 - using svn standard dir structure for a project

  1. svn mkdir --parents /path/to/your/project/root/trunk /path/to/your/project/root/branches /path/to/your/project/root/tags -m "standard svn project folders"
  2. git svn init /path/to/your/project/root -s
  3. git svn fetch
  4. git rebase trunk

Committing Changes
  1. git add -A
  2. git commit -m "adding my changes, including new files"
  3. git svn dcommit
  4. git log

No comments:

Post a Comment