Search code examples
c#.netlibgit2sharp

How to detect pending changes in libgit2sharp?


In libgit2sharp https://github.com/libgit2/libgit2sharp/ how do you check for pending/uncommitted changes?


Solution

  • The following works for me:

    ///DEPRECATED - see comment from @derptastic
    public bool HasUncommittedChanges
    {
        get
        {
            using (var repo = new Repository(repositoryRoot))
            {
                RepositoryStatus status = repo.RetrieveStatus();
                return status.IsDirty;
            }
        }
    }
    

    Thanks to @Derptastic for the link to LibGit2Sharp Wiki