【问题标题】:libgit2sharp - how to undo the change in working copy only?libgit2sharp - 如何仅撤消工作副本中的更改?
【发布时间】:2021-05-11 23:48:00
【问题描述】:

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

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

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

谢谢,

【问题讨论】:

  • 问题本质上是如何用libgit2sharp实现“git checkout --filepath”。

标签: libgit2sharp


【解决方案1】:

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

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

其中filepatha.txt 的路径

【讨论】:

    猜你喜欢
    • 2010-10-18
    • 2010-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-23
    • 2015-07-21
    • 2010-09-26
    • 1970-01-01
    相关资源
    最近更新 更多