如果文件

问题描述

我正在寻找一种方法来丢弃所有带有路径的文件更改。

在 libGit2Sharp 中存在方法

Checkoutoptions options = new Checkoutoptions { CheckoutModifiers = CheckoutModifiers.Force };

repo.CheckoutPaths("49916",checkoutPaths,options);

但我在 libgit2 API

中没有看到类似的方法

如何重置文件以启动 head 提交的状态?


我不需要取消暂存更改——我需要将单个文件完全恢复到头部提交状态。

解决方法

使用git_checkout_tree。为 NULL 传递 treeish 以重置为 HEAD 提交。在 opts.paths 中传递要重置的路径并将 opts.checkout_strategy 设置为 GIT_CHECKOUT_FORCE。您可能还想将 GIT_CHECKOUT_DISABLE_PATHSPEC_MATCHcheckout_strategy 加入 const { Socket } = require("net") class Client { connect () { this.a = new Socket() this.a.connect(this.port,this.host) this.socket = new Socket() this.socket.connect(this.port,this.host) } } 以禁用通配符匹配。