【发布时间】:2017-11-10 23:05:13
【问题描述】:
我想做与git checkout -- file 等效的操作,以丢弃尚未暂存以供提交的文件中的更改。
我已经看到关于how to checkout from a specific commit 的问题,但是我不想指定任何特定的提交或分支。
在以下代码中,commitishOrBranchSpec 的参数似乎是必需的,但不能为 null 或空字符串;有没有可以在这里指定一个值来表示default,类似于上面的git命令行中没有指定任何分支或提交?
using (var repo = new Repository(workingDir))
{
// $TODO: Figure out what to pass for parameter 1,
// commitishOrBranchSpec (null and "" don't work)
repo.CheckoutPaths("", Enumerable.Repeat(filePath, 1));
}
【问题讨论】:
标签: git git-checkout libgit2 libgit2sharp