Improve handling of workdir and index in GitRepository