Clean index before git reset and when clearing depot

git index is cleaned on clear operations.

`git read-tree empty` is used before `git reset` as `git reset` can have nasty behaviours with unmerged files in the index.

`reset` is used with `pygit2` as it implicitelly cleans the index.

I tried to do a test reproducing the issue we had in Tuenti, but I couldn't, in any case this code is able to recover the working copies we broke.