Getting a Current Subversion Project Into Git Control

Whilst learning how to use git with svn I am documenting the way I’ve done it. I’m using bash and am starting from the directory above my working directory. The project is checked out already from an svn repo. The working directory is “efot”.

  • Commit anything outstanding in your working directory to svn
  • Move your working directory out of the way if you’re paranoid like me: mv efot efot.pregit
  • Checkout (clone) your project from svn using git: git-svn clone http://svnServer/repos/section/trunk/efot --username=yourSvnName
  • Watch what’s happening: cd efot;gitk &
  • Make sure git ignores .svn and, since I use eclipse in an heterogenous env with other developers, I exclude bin/, and *.log as well:
    • vim .git/info/exclude
    • add “.svn” (without the quotes) to the bottom of the file
    • newline, add “bin” (without the quotes) to the bottom of the file
    • newline, add “*.log” (without the quotes) to the bottom of the file
    • save and quit.
  • Make sure svn will ignore git files and local files I don’t commit to the trunk:cd .. && svn ps svn:ignore ".git" efot && cd efot
    cd .. && svn ps svn:ignore ".classpath*" efot && cd efot
  • cd .. && svn ps svn:ignore ".settings" efot && cd efot

  • give it a descriptive label in git: git-tag -a 20090310_efot_release_prod

Now for the paranoid amongst us, cross the i’s and dot the t’s ;):

  • cp -R ../efot.pregit/src . ; cp -R ../efot.pregit/testsrc .;cp -R ../efot.pregit/xml;cp ../efot.pregit/.classpath . ; cp ../efot.pregit/.settings .;
  • git add .
  • git commit -a
  • update from svn: git-svn fetch
  • if any come in on the fetch, replay any git changes onto it (shouldn’t be any at this point): git-svn rebase
  • commit to svn: git-svn dcommit

Job’s a good’un. I think.

Refs: Git User’s Manual, Flavio Castelli, and Git Crash Course.

Advertisements
This entry was posted in 1. Bookmark the permalink.

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s