Lately I have been reading about and toying with Git a lot — and I’m truly fascinated! (In fact, I’m even using it to track the progress of this very posting.)
However, I’m not primarily interested in the distributed part. More important, to me, is the fact that Git gives me a private revision history (local commits). That way I can commit frequently without having to worry about publishing my changes prematurely.[1]

Since for TiddlyWiki we’re using Subversion, I’ve started looking into Git’s SVN module. With this I can use Git locally while still interacting with the public Subversion repository.

The following guide is to serve as a quick introduction to Git-SVN, hopefully making it easy for others (e.g. fellow Osmosoftonians) to get started.
Note that I’m an enthusiastic command-line user, which is why this guide does not cover any GUIs. Also, I’m far from being a Git expert at this point, so feel free to suggest improvements!

Initial Setup

  • check out Subversion repository:[2][3]

    git-svn clone -T[trunk_subdir] -t[tags_subdir] -b[branches_subdir] [URL]

    (e.g. git-svn clone -TTrunk -tTags -bBranches http://svn.tiddlywiki.org)

  • create branch for work in progress (WIP):

    git checkout -b [branch]

Working with Git

  • modify files on WIP branch, creating (and amending) local commits:[4]

    git add [files]
    git commit -m "[message]"
    git commit --amend
  • switch to master branch:

    git checkout master
  • grab changes from WIP branch:[5]

    git merge --squash [branch]
  • commit changes and push to Subversion:[6]

    git commit -a -m "[message]"
    git-svn dcommit
  • switch back to WIP branch:[7]

    git checkout [branch]
    git merge master

Useful Commands

Thanks to Kerry for getting me started with Git in the first place!

  1. The same is true for other DVCS, like Mercurial — though I have only worked with Git so far. []
  2. Cloning an entire Subversion repository can take a while (mostly due to protocol overhead) — an alternative is to grab only the latest revision: git-svn init [URL]; git-svn fetch -r HEAD. []
  3. Instead of manually specifying directory names for trunk, tags and branches, -s can be used for the standard naming convention “trunk”, “tags” and “branches”. []
  4. Use git commit -a -m "[message]" to automatically add all modified files. []
  5. Squashing means that several local commits can be merged into a single commit. []
  6. dcommit will automatically perform an update (rebase). []
  7. The merge operation is required due to the rewritten commit history on the master. []
  8. My current .gitconfig file:

    [user]
    	name = FND
    [alias]
    	ci = commit
    	cia = commit -a
    	cim = commit -m
    	ciam = commit -a -m
    	co = checkout
    	diffi = diff --color-words
    	diffw = diff -w
    	diffx = diff -w --color-words
    [color]
    	branch = auto
    	diff = auto
    	status = auto
    [color "branch"]
    	current = yellow reverse
    	local = yellow
    	remote = green
    [color "diff"]
    	plain = white
    	meta = yellow bold
    	frag = magenta bold
    	old = red bold
    	new = green bold
    [color "status"]
    	header = white
    	added = yellow
    	changed = green
    	untracked = cyan

    []