git - getting git-svn to work
I’ve been working with the async-msgcomp svn repository by creating a single working directory with both .git and .svn directories. I then setup each to ignore the others files as well as some files Eclipse uses that should be in the scm. My .git/info/exclude file contains:
bin .metadata R.java .svn
My [miscellany] section of ~/.subversion/config [miscellany] contains:
global-ignores = .git bin R.java *.class .metadata *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store
This was fine but did make things laborious as I had to checkin twice, one for each and maintaining the commit comments was painful. At first I figured I do several git checkins then a svn checkin, but it turns out 1:1 seems to work fairly well.
But there is a better way, git-svn, I did find a quick cheat sheet here with the following a suggested work-flow:
git svn clone -s <svn_repo> git checkout -b <work_branch> ...hack...hack... git commit -a git checkout master git svn rebase git merge <work_branch> #NOTE: no need for --squash anymore git svn dcommit -e # -e will let you enter a commit message for SVN
When I first tried the first statement (git svn clone <svn_repo> failed with:
Can't locate SVN/Core.pm in @INC
Searching the Net it turns out I needed to install libsvn-perl via apt/synaptic, after doing so I could clone the async-msgcomp repo using:
git svn clone -s https://async-msgcomp.googlecode.com/svn --username wink@saville.com async-msgcomp
This looks like a pretty good introduction to git-svn, the only problem is that its for pre 1.5.3.4 and includes the need for a –squash on the merge.
After cloning the svn repo, I also want a backup git repo on my server. Turns out that just following my instructions for setting a remote git repo worked perfectly (actually, doing this led me to find how to use the “git add remote”.
I have run into one problem, if the my git server repo gets out of sync with the svn repo I’m in trouble. The symptom of the trouble is an attempt to push the local repo to the server gets refused because its not a fast forward. This happens if I push to the server before doing the git svn dcommit. The git svn dcommit command places another commit on the local and hence if I’ve all ready pushed before the dcommit it won’t push.
The quickest solution is to remove the current remote, recreate an empty repo on the server as before and push it out again. Alternatively is start all over with a new git svn clone.