make switching to a given git revision more robust

When the cache is enabled, if a branch (say) is switched to, and then
later on the same branch is switched to again after its history has
been rewritten, then an approach based on git pull will often result
in a merge conflict.  Similarly, if a tag was previously checked out,
git pull on a branch would fail due to being in detached HEAD state.
With the new approach of using a temporary branch and git reset
--hard, neither of these problems should never occur.
add some docstrings to a few of the more complex tests
leave temporary files behind on failure, for debugging
a bit more info on the test suite