The company I am currently at haven’t yet made the jump to git. It’s understandable; there are a number of large SVN repositories and only one (or two) of the developers know how to use git. So, it doesn’t make sense right now. I’m trying to get git-svn working accurately in my workflow before I try and explain the awesome-ness of git for my colleagues. I’ve run into two problems, one is svn:properties and how git doesn’t support them (except ignore) which is a pain, because it means that if I want to adhere to AWin coding standards and not have PHPUnderControl moan at me, I need to have svn:keywords and svn:EOL properties for each file. The hacky fix is to run a seperate SVN directory on my box, which I add files to, add the properties, then rebase them into git. It’s a pain.
The other problem is ReviewBoard. Well, it’s not such a massive problem now ReviewBoard has ‘post-review’ which allows you to send reviews to RB via the command line. But, sometimes, you just want a standard diff file which you can upload to RB, git diff doesn’t create files that ReviewBoard understands, which is where a little bit of bash scripting comes into play.
I found this: My (work) Git Workflow (You should read it all, it goes into managing branches and stuff, it’s a useful read if you’re just starting out with git-svn, thanks Seth!). Which almost worked. Except, for some reason, it was pumping out massive diff files that git diff wasn’t. So, I had a little bit of a fiddle and found that it uses the git config option svn-remote. Which, for my repo is set to the trunk. Which doesn’t make any sense if I want to run an diff on the branch I’m working on, so, I modified it:
#!/bin/bash # # git-svn-diff originally by (http://mojodna.net/2009/02/24/my-work-git-workflow.html) # modified by firstname.lastname@example.org # # Generate an SVN-compatible diff against the tip of the tracking branch # Get the tracking branch (if we're on a branch) TRACKING_BRANCH=`git svn info | grep URL | sed -e 's/.*\/branches\///'` # If the tracking branch has 'URL' at the beginning, then the sed wasn't successful and # we'll fall back to the svn-remote config option if [[ "$TRACKING_BRANCH" =~ URL.* ]] then TRACKING_BRANCH=`git config --get svn-remote.svn.fetch | sed -e 's/.*:refs\/remotes\///'` fi # Get the highest revision number REV=`git svn find-rev $(git rev-list --date-order --max-count=1 $TRACKING_BRANCH)` # Then do the diff from the highest revition on the current branch git diff --no-prefix $(git rev-list --date-order --max-count=1 $TRACKING_BRANCH) $* | sed -e "s/^+++ .*/& (working copy)/" -e "s/^--- .*/& (revision $REV)/" \ -e "s/^diff --git [^[:space:]]*/Index:/" \ -e "s/^index.*/===================================================================/"
You can also see it here: http://gist.github.com/582239
So far, it seems to be working for me. But it’s only until I get the department using git right, RIGHT?