Allow working directory to be overridden on the command line.
Handle various additional detached head checkout scenarios. Add tests for those scenarios and documentation for how version is determined.