本文介绍了以编程方式删除克隆存储库的目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 LibGit2Sharp 将远程存储库克隆到Windows临时文件夹中。我的脚本完成后,我想清理。但是,我总是得到以下错误:

其中 pack-efcef325f8dc897099271fd0f3db6cf4d9f12393.idx $中的文件local_git_clone_path\objects\pack。



如何完全删除我使用LibGit2Sharp克隆的git repo的所有本地剩菜?

解决方案

我记得遇到类似的情况。

而且,正如@nulltoken所建议的,您必须 Dispose() Repository ,然后尝试删除它所拥有的文件。



使用应该是最好的选择。

 使用(var repo = new Repository(repositoryPath))
{
//您的特定于回购的实现。
}

//代码删除你的本地临时目录

参考:来自LibGit2Sharp的


I am using LibGit2Sharp to clone a remote repository into the windows temp folder. After my script has completed, I want to clean up. However, I always get the following error:

where pack-efcef325f8dc897099271fd0f3db6cf4d9f12393.idx is a file in $local_git_clone_path\objects\pack.

How can I completely delete all local leftovers of the git repo I cloned using LibGit2Sharp ?

解决方案

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

这篇关于以编程方式删除克隆存储库的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 17:40