Soenneker.Git.LibGit2Sharp
4.0.332
Prefix Reserved
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
<PackageReference Include="Soenneker.Git.LibGit2Sharp" Version="4.0.332" />
<PackageVersion Include="Soenneker.Git.LibGit2Sharp" Version="4.0.332" />
<PackageReference Include="Soenneker.Git.LibGit2Sharp" />
paket add Soenneker.Git.LibGit2Sharp --version 4.0.332
#r "nuget: Soenneker.Git.LibGit2Sharp, 4.0.332"
#:package Soenneker.Git.LibGit2Sharp@4.0.332
#addin nuget:?package=Soenneker.Git.LibGit2Sharp&version=4.0.332
#tool nuget:?package=Soenneker.Git.LibGit2Sharp&version=4.0.332
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 | Versions 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. |
-
net10.0
- LibGit2Sharp (>= 0.32.0)
- Polly (>= 8.7.0)
- Soenneker.Extensions.Configuration (>= 4.0.872)
- Soenneker.Utils.Directory (>= 4.0.916)
- Soenneker.Utils.Process (>= 4.0.1534)
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 |
Updated NuGet packages