使用 libgit2sharp 更改文件夹的大小写



当它只是大小写更改时,如何在libgit2sharp(在Windows下,不区分大小写(中重命名目录?

此代码适用于跨不同目录移动文件:

File.Move(@"C:repofolder1file.txt", @"C:repofolder2file.txt");
repo.Index.Remove("folder1/file.txt");
repo.Index.Add("folder2/file.txt");
repo.Index.Write();
var commitResult = repo.Commit(logMessage, author, author);

但是,如果我只是重命名文件夹的大小写,则不起作用:

Directory.Move(@"C:repofolder1", @"C:repoFolder1");
repo.Index.Remove("folder1/file.txt");
repo.Index.Add("Folder1/file.txt");
repo.Index.Write();
var commitResult = repo.Commit(logMessage, author, author); // nothing gets written - I get LibGit2Sharp.EmptyCommitException

我还尝试按照这个答案的建议进行 2 次重命名(并在最后提交一次(

我做错了什么还是这是 git 限制? 除了执行中间提交之外,还有其他解决方法吗?

PS:我尝试将存储库更改为忽略大小写= false(Windows中的默认值为true(,但它也不起作用。

事实证明,在 git.config 中设置ignorecase=false就足够了 - 但我必须从一开始就使用它(在第一次提交之前(。

我只是在我真正删除旧案例并添加新案例的那一刻尝试更改该设置,看起来这还不够 - git 无法检测到更改。

最新更新