首页 > 解决方案 > libgit2sharp - 如何仅撤消工作副本中的更改?

问题描述

给定存储库中已经存在的文件 a.txt,我们执行以下操作 - modify-stage-modify(again)。

如何撤消工作副本的更改(基本上将其还原为暂存版本)?

我尝试了 Repository.CheckoutPaths(),但它取消了工作副本和暂存副本。

谢谢,

标签: libgit2sharp

解决方案


您是否尝试指定文件路径?

using(var repo = new Repository("path"))
{
   var opt = new CheckoutOptions();
   repo.CheckoutPaths(repo.Head.Tip.Id.Sha, new string[] { "filepath" }, opt); 
}

filepath去哪里a.txt


推荐阅读