nix-prefetch-git: fix determinism with leaveDotGit

Remove all remote branches, remove tags not reachable from the given
'rev', do a full repack and then garbage collect unreferenced objects.

According to my testing, the result is fully deterministic. As in "any
change done to the upstream repo, ahead of 'rev', will not affect the
output hash". But only time will tell.

A new version of git can of course change store format, but that's
unavoidable.

For big repositories, the repack operation may be a bit heavy. But as
far as I can see there is no cheaper way to determinism.