Fix fetching a specific head

Remotes were stored in a table by their hash, which made some
remotes disappear when e.g. a tag or a branch was present at
the same commit. Now they are accessed by name.