Soenneker.Git.LibGit2Sharp 4.0.332

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Git.LibGit2Sharp --version 4.0.332
                    
NuGet\Install-Package Soenneker.Git.LibGit2Sharp -Version 4.0.332
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Git.LibGit2Sharp" Version="4.0.332" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Git.LibGit2Sharp" Version="4.0.332" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Git.LibGit2Sharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Git.LibGit2Sharp --version 4.0.332
                    
#r "nuget: Soenneker.Git.LibGit2Sharp, 4.0.332"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Git.LibGit2Sharp@4.0.332
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Git.LibGit2Sharp&version=4.0.332
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Git.LibGit2Sharp&version=4.0.332
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.Git.LibGit2Sharp

A DI-ready wrapper for cloning, inspecting, fetching, pulling, committing, and pushing Git repositories, including bulk operations beneath a directory.

Install

dotnet add package Soenneker.Git.LibGit2Sharp

Registration

using Soenneker.Git.LibGit2Sharp.Registrars;
using Microsoft.Extensions.DependencyInjection;

services.AddLibGit2SharpUtilAsSingleton();

Scoped registration is also available through AddLibGit2SharpUtilAsScoped().

Authentication defaults are read from configuration:

{
  "Git": {
    "Token": "<GitHub token>",
    "Name": "Commit author",
    "Email": "author@example.com"
  }
}

Token is used by clone, fetch, and pull. Name and Email are used when pull or commit does not receive explicit author values. Push receives its token as a method argument.

Examples

ILibGit2SharpUtil git = serviceProvider.GetRequiredService<ILibGit2SharpUtil>();

string checkout = await git.CloneToTempDirectory(
    "https://github.com/example/project.git",
    cancellationToken);

if (git.IsRepositoryDirty(checkout))
{
    git.Commit(checkout, "Update generated files");
    await git.Push(checkout, token, cancellationToken);
}

Bulk methods discover repository roots recursively and then apply the requested operation sequentially. Once a repository is found, nested directories beneath that root are not treated as separate repositories.

API at a glance

API What it does Result / important behavior
Clone, CloneToTempDirectory Clone into a chosen or newly created temporary directory. Requires Git:Token; the caller owns temporary-directory cleanup.
Fetch, Pull Update remote references or integrate upstream changes. Pull fails on conflicts and does not create a merge commit automatically.
Commit, Push, CommitAndPush Stage changes, create a commit, and/or push local main. No commit is created for a clean repository.
IsRepository, IsRepositoryDirty Inspect a directory. Does not mutate the repository.
GetAllGitRepositoriesRecursively, GetAllDirtyRepositories Discover repository roots beneath a directory. Returns materialized paths.
*AllGitRepositories, CommitAllRepositories, PushAllRepositories Apply an operation to every discovered repository. Runs sequentially and stops when an operation fails.
SwitchToRemoteBranch Checkout local main. Does not force or discard conflicting working-tree changes.
RunCommand Run arbitrary Git arguments in a working directory. Inputs must be trusted; this is intentionally a raw command escape hatch.

Practical notes

  • LibGit2Sharp operations are synchronous; cancellation applies to directory discovery, process execution, retry waits, and async orchestration rather than interrupting an in-progress native Git operation.
  • Methods mutate real repositories and remotes. Use a token with only the permissions required by the target repository.
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.333 0 9/3/2026
4.0.332 35 9/1/2026
4.0.331 49 8/31/2026
4.0.330 43 8/31/2026
4.0.329 48 8/31/2026
4.0.328 56 8/30/2026
4.0.327 49 8/30/2026
4.0.326 54 8/29/2026
4.0.325 47 8/29/2026
4.0.324 48 8/29/2026
4.0.323 79 8/26/2026
4.0.322 83 8/26/2026
4.0.321 83 8/26/2026
4.0.320 85 8/26/2026
4.0.319 88 8/25/2026
4.0.318 88 8/22/2026
4.0.317 87 8/22/2026
4.0.316 100 8/22/2026
4.0.315 96 8/22/2026
4.0.314 96 8/18/2026
Loading failed

Updated NuGet packages