Soenneker.Git.LibGit2Sharp 4.0.336

Prefix Reserved
This package has not been indexed yet. It will appear in search results and will be available for install/restore after indexing is complete.
The package icon will become available after this package is indexed.
dotnet add package Soenneker.Git.LibGit2Sharp --version 4.0.336
                    
NuGet\Install-Package Soenneker.Git.LibGit2Sharp -Version 4.0.336
                    
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.336" />
                    
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.336" />
                    
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.336
                    
#r "nuget: Soenneker.Git.LibGit2Sharp, 4.0.336"
                    
#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.336
                    
#: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.336
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Git.LibGit2Sharp&version=4.0.336
                    
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.336 0 9/4/2026
4.0.335 0 9/4/2026
4.0.334 0 9/4/2026
4.0.333 30 9/3/2026
4.0.332 49 9/1/2026
4.0.331 62 8/31/2026
4.0.330 55 8/31/2026
4.0.329 60 8/31/2026
4.0.328 67 8/30/2026
4.0.327 60 8/30/2026
4.0.326 65 8/29/2026
4.0.325 58 8/29/2026
4.0.324 59 8/29/2026
4.0.323 84 8/26/2026
4.0.322 88 8/26/2026
4.0.321 87 8/26/2026
4.0.320 88 8/26/2026
4.0.319 90 8/25/2026
4.0.318 89 8/22/2026
4.0.317 88 8/22/2026
Loading failed

Updated Soenneker.Utils.Process to 4.0.1543