【发布时间】:2015-10-09 05:13:42
【问题描述】:
如果我有这个状态的回购
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: App_Data/Submodule
modified: file.txt
App_Data/Submodule 是一个 git 子模块,file.txt 只是一个普通文件。
运行 git checkout master --force 会将 repo 置于此条件下
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: App_Data/Submodule (new commits)
no changes added to commit (use "git add" and/or "git commit -a")
但使用以下代码从 LibGit2Sharp 执行相同操作
using (var repo = new LibGit2Sharp.Repository(RepositoryPath))
{
repo.Checkout("master", new CheckoutOptions { CheckoutModifiers = CheckoutModifiers.Force });
}
让仓库保持这种状态
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: App_Data/Submodule
调用 reset 但按预期工作。
using (var repo = new LibGit2Sharp.Repository(RepositoryPath))
{
repo.Reset(ResetMode.Hard, "master");
}
LibGit2Sharp 是否会出现这种行为?如果我想反映完全相同的 git 行为,我应该自己调用 Reset 吗?
【问题讨论】:
标签: c# libgit2sharp