'LibGit2Sharp takes forever to stage

Using Lib2GitSharp. I know shallow clone is not supported, but I still need to clone a large repo, make some changes, stage and check it in. It's taking almost an hour to stage the changes. I've tried a couple of ways. You can see I've tried Commands.Stage(repo, "*") as well as looping through the status. Is there a faster way?

    public void StageChanges(string clonePath)
    {
        try
        {
            _logger.LogInformation($"Staging repo");
            Repository repo = new Repository(clonePath);

            // Commands.Stage(repo, "*");
            var status = repo.RetrieveStatus();
            if (status.Modified.Any())
            {
                foreach (var file in status.Modified)
                {
                    Commands.Stage(repo, file.FilePath);
                }
            }

            _logger.LogInformation($"Staged repo");
        }
        catch (Exception e)
        {
            _logger.LogError(e, $"Error staging file path {clonePath}");
            throw;
        }
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source