add post-rewrite hook to update VERSION

This addresses #326, but doesn't quite fix it as the branch name is still wrong. Probably need to read the old hashes from stdin to address that.
don't read branch more than once