Improve handling of pinned packages

This set of commit improves the handling of detached HEAD, and simplifies the update logic in the git importer quite a lot in the process.

So far, the git importer would create a detached HEAD when pinned to a commit or tag. This is really really confusing for users, as using git on a detached HEAD is weird (and it is easy to "lose" data when using them).

Instead, after this pull request, the importer will NEVER create a detached HEAD. It will checkout the branch setup in the importer (i.e. the "local branch") and either reset it to the pinned commit if all other commits are present remotely, or generate an error.

Uncommitted changes are handled the way "git checkout" handles them. That is, they are applied on the new HEAD if possible, or the reset is aborted (with error) if they don't.