I'm writing a book about RSpec and need to deliver code samples by chapter/section to the publisher. This is a pretty dirty but fast way of doing so; essentially I identify each check in's revision in my check in message (I used the section name as the check in message) and plugged them into the following shell script. Note that there are ../working and ../delivery directories (relative to the GIT_SRC directory) that get plastered and filled during this process!

# package-src.sh  
#!/bin/bash

GIT_SRC=~/Projects/book/src  
DEST\_TAR\_GZ=project  
REVS="48c7ed8 7c19f89 30e195f 4f75557 9cf5aea"

cd $GIT_SRC  
rm -rf ../working  
mkdir -p ../delivery  
rm -rf ../delivery/*.tar ../delivery/*.tar.gz  
git clone . ../working  
cd ../working

for REV in $REVS; do  
  git co $REV
  FILENAME=$(git log -n1 | tail -n1 | cut -c 5-256 | tr ' ' _)
  tar cf ../delivery/$FILENAME.tar --exclude=".git/" .
done

cd ../delivery  
tar czf ${DEST_TAR_GZ}.tar.gz *.tar