How to use unison svn with git

Table of Contents

1 How to use unison svn with git

1.1 Initial cloning

The last two lines are only necessary if one wants to synchronize directly with the subversion server (either to update or to push commits).

git clone -o mirror https://forge.ocamlcore.org/anonscm/git/unison-mirror/unison-mirror.git unison
cd unison
git svn init --prefix=mirror/svn/ -s https://webdav.seas.upenn.edu/svn/unison
git config svn.authorsfile unison_authors.txt

1.2 Keeping up to date

git pull --rebase

The git repository is synchronized with the central subversion repository every five minutes. If one needs to update directly from subversion, then do the following.

git svn rebase

1.3 Making changes

git pull --rebase               [ensure up to date with mirror]
....                            [modify a file]
git add -A                      [add any changes in files to the index]
git ci -m "updated a file"      [commit the changes in the index]
git svn rebase                  [ensure up to date with svn]
git svn dcommit                 [push changes back to subversion]

1.4 Working with branches

From my limited understanding, subversion does not know how to deal with merge commits, and pushing commits with merge commits may result in them being squashed thus with some information (log, author) missing. The best practice is then to only push commits that start at the end of the current subversion branch (i.e., these commits can be "fast-forwarded"). To this end, one has to "rebase" commits to bring them forward when things change upstream.

git checkout -b feature         [create a feature branch and checkout]
....                            [modify a file]
git add -A                      [add any changes in files to the index]
git ci -m "updated a file"      [commit the changes in the index]

Don't forget to occasionally rebase from mirror and rebase the branch from `svn/trunk`.

git checkout svn/trunk          [switch back to the master branch]
git pull --rebase               [ensure up to date with mirror]
git checkout feature            [switch back to the feature branch]
git rebase svn/trunk            [replay branch changes on top of master and fix any problems]
....                            [do some work, until you are ready to commit back to svn]
git checkout svn/trunk          [switch back to the master branch]
git svn rebase                  [ensure up to date with svn]
git checkout feature            [switch back to the master branch]
git rebase svn/trunk            [replay branch changes on top of master and fix any problems]
git checkout svn/trunk          [switch back to the master branch]
git merge feature --ff-only     [merge feature branch ensuring fast forward merge]
git svn dcommit                 [push changes back to subversion]

Date: 2012-03-21 17:50:05 CET

Author: Alan Schmitt

Org version 7.8.03 with Emacs version 23

Validate XHTML 1.0