I remember having faced a similar situation.
And, as advised by @nulltoken, you would have to Dispose()
the Repository
before trying to delete the files that are being held by it.
using
should be the best option.
using (var repo = new Repository(repositoryPath))
{
//Your repo specific implementation.
}
//Code to Delete your local temp dir
Reference: Clone Fixture from LibGit2Sharp