git How-To WebApps

Getting Around the Politics of Subversion with git

This is the nightmare scenario. You are working with a coder who overwrites your changes in subversion. You’ve told this coder once, twice, three times, “Hey, please don’t do that. Hey, let’s talk about your changes before you commit them.”

But this coder for some reason thinks that he or she is the gift of the gods when it comes to coding, and continues to overwrite your changes.

This is where git comes in. If I had learned about this feature of git and the idea of accepting or rejecting changes in git sooner, I would have avoided the whole nightmare of re-comitting code and lengthy merge debates.

Most projects you work won’t involve the worst case above. Most of the time, there will be a great developing rule that says never commit bugs into subversion. But whenever you have to re-factor code and commit each line, branching and then later merging can be an issue in subversion, and it’s slow too.

On a project that I’m working on now the client wants only good code in svn which is great, and so I’m using git with svn. I got this idea thanks to Jakob Heuser. Thanks, Jakob!!!!

This is where git comes in. Here’s a quick cheat sheet and it assumes you are using GitHub:

mkdir newlispoauth
cd newlispoauth/
git init
touch README
git add README
git commit -m ‘first commit’
git remote add origin
git push origin master

Now we have to pull in changes from subversion:

mate .git/config

In the config file add something that looks like this:

[svn-remote “newlispoauth/trunk”]
  url =
  fetch = :refs/remotes/newlispoauth/trunk

Now we’re gonna fetch the subversion repo:

git-svn fetch newlispoauth/trunk
git checkout -b local-svn/trunk newlispoauth/trunk
git svn rebase
git checkout master
git merge local-svn/trunk
git mergetool # if there are conflicts with the README file above
git add README # if you had to make changes with the mergetool
git commit
git push origin master

Now you are working with “master” and “local-svn/trunk”.

“master” is for your changes to share with your team on git-hub
“local-svn/trunk” is for you and where you push changes to subversion.

You basically pull in changes from newlispoauth/trunk and do your work in local-svn/trunk.

Let’s put the changes in master into “newlispoauth/trunk” and commit those changes to subversion:

git checkout local-svn/trunk # you did commit your changes in origin right?
git merge master
git-svn dcommit
How-To WebApps

Saving Time on Subversion Merging: svn merge Manually

I just ran a benchmark on merging files using Eclipse which then calls subversion and running subversion manually on a 28MB repository.

The results are interesting.

svn merge destination_url@HEAD source_url@HEAD destination_folder

took exactly 7 minutes

Using a subversion merge in eclipse on the same repo and revision took 10 minutes.

Take away: use svn merge on the command-line.

Ya, I’d love to go back to using git.

How-To WebApps

Weening Myself Off of Eclipse PDT

I really just want to stick with Vim, and Vim is really making that sort of commitment easy because of technology I talked about in my last post, as well as learning how to use subversion just from the command-line.

Today I learned how to:

  • create folds in Vim with a split view so that I can get perspectives similar to Eclipse’s object explorer. (There’s a great folds tutorialon
  • merge by just using subversion on the command-line

Tomorrow I’m gonna learn about:

  • Using ant at the command-line
  • Being more adept at file version comparisons, e.g. (svn diff)

Have you weened yourself off of an IDE? And if so, what do you now use for text editing?