我想要执行相当于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));
}发布于 2016-06-14 16:54:56
我已经看到了关于如何从特定提交中签出的问题,但是我不想指定任何特定的提交或分支。
您必须指定要签出的内容。如果您想模仿git checkout -- file,那么您可以简单地使用HEAD分支。例如:
repo.checkoutPaths(repo.Head, new string[] { filePath }, checkoutOptions);https://stackoverflow.com/questions/36670989
复制相似问题