Removing a cloned repo

296 views Asked by At

I'd like to remove a cloned repo on disk using NGit, which is a port of JGit.

I've previously done this to clone a remote repo locally:

System.IO.Directory.CreateDirectory(someDir);
var clone = Git.CloneRepository().SetDirectory(someDir).SetURI(someRepoUri);
Git Repo = clone.Call();

I'd like now to delete that local directory containing that cloned repo.

I was receiving permission exceptions when simply calling System.IO.Directory.Delete() when it reached the .git\objects\pack\*.idx files. Perhaps this is just a side effect of running this on Windows Azure.

Is there an NGit command I can issue to have the .git directory and all its contents removed by using functionality within NGit?

1

There are 1 answers

1
VonC On

Make sure you don't have any existing git/NGit process which you keep an handle on those resources (.git\objects\pack\*.idx files).

Not killing those processes is generally the reason for those "rm: cannot unlink ..." error messages.