在 libgit2sharp https://github.com/libgit2/libgit2sharp/你如何检查挂起/未提交的更改?
问问题
5560 次
3 回答
19
以下对我有用:
///DEPRECATED - see comment from @derptastic
public bool HasUncommittedChanges
{
get
{
using (var repo = new Repository(repositoryRoot))
{
RepositoryStatus status = repo.RetrieveStatus();
return status.IsDirty;
}
}
}
感谢@Derptastic 提供指向LibGit2Sharp Wiki的链接
于 2015-05-18T19:51:13.047 回答
7
以下代码行将提供文件名和该文件的状态。
foreach (var item in repo1.RetrieveStatus())
{
Console.WriteLine(item.FilePath);
Console.WriteLine(item.State);
}
于 2015-11-18T08:47:42.130 回答
5
您可以使用repository.Diff.Compare()
.
/// <summary>
/// Show changes between the working directory and the index.
/// </summary>
/// <param name = "paths">The list of paths (either files or directories) that should be compared.</param>
/// <returns>A <see cref = "TreeChanges"/> containing the changes between the working directory and the index.</returns>
public virtual TreeChanges Compare(IEnumerable<string> paths = null)
根本不通过任何路径应该会给出所有更改。
于 2012-10-13T13:32:13.500 回答