Soenneker.Git.Util 11.0.3901

Prefix Reserved
dotnet add package Soenneker.Git.Util --version 11.0.3901
                    
NuGet\Install-Package Soenneker.Git.Util -Version 11.0.3901
                    
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.Util" Version="11.0.3901" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Git.Util" Version="11.0.3901" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Git.Util" />
                    
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.Util --version 11.0.3901
                    
#r "nuget: Soenneker.Git.Util, 11.0.3901"
                    
#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.Util@11.0.3901
                    
#: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.Util&version=11.0.3901
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Git.Util&version=11.0.3901
                    
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.Util

Asynchronous Git operations backed by bundled Windows and Linux Git distributions, with repository discovery and optional bounded parallel execution across multiple repositories.

Install

dotnet add package Soenneker.Git.Util

Configure and register

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

services.AddGitUtilAsSingleton();

Scoped registration is available through AddGitUtilAsScoped().

The utility reads its default credentials and branch once when it is constructed:

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

Token, Name, and Email are required configuration values. A token supplied to an individual method overrides the configured token. Authentication is non-interactive and is applied to GitHub HTTPS requests without putting the token in the remote URL or command log.

Common operations

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

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

await git.Fetch(checkout, cancellationToken: cancellationToken);

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

CloneToTempDirectory returns a shallow clone and transfers ownership of that temporary directory to the caller.

Repository discovery and batches

IReadOnlyList<string> dirty =
    await git.GetAllDirtyRepositories(@"C:\git", cancellationToken);

await git.FetchAllGitRepositories(
    @"C:\git",
    parallel: true,
    cancellationToken: cancellationToken);

Discovery accepts either a repository root or a directory containing repositories. Batch operations are sequential by default. With parallel: true, concurrency is bounded to at most eight repositories and the processor count.

API at a glance

API What it does Result / important behavior
Clone, CloneToTempDirectory Clone a repository, optionally with blob filtering and depth one. Temporary clones must be deleted by the caller.
Fetch, Pull, Push, PullAndPush Exchange commits with origin using the configured branch. Failures propagate to the caller.
Commit, CommitAndPush Stage all changes and create a commit when anything is staged. Uses explicit identity values or the configured defaults.
IsRepository, IsRepositoryDirty, HasStagedChanges, HasWorkingTreeChanges Inspect repository state. IsRepositoryDirty also detects upstream divergence.
GetAllGitRepositoriesRecursively, GetAllDirtyRepositories Find repository roots beneath a directory. Also recognizes worktree and submodule .git files.
*AllRepositories methods Apply fetch, pull, commit, push, integrity, or maintenance operations to discovered repositories. Can run sequentially or with bounded parallelism.
Run Execute arbitrary arguments with the bundled Git binary. This is a raw escape hatch; only pass trusted arguments.

Synchronization and recovery safety

SwitchToRemoteBranch fetches origin, then checks out the configured branch only when the working tree is clean and local HEAD is an ancestor of the remote branch. It refuses uncommitted changes, unpushed commits, and divergent history instead of resetting or cleaning them.

GarbageCollectOrReclone is intended for repository recovery. If garbage collection fails, it clones a replacement beside the repository first, swaps it into place only after cloning succeeds, and restores the original directory if the swap fails. A successful replacement intentionally discards local-only repository state, so use this method only when recloning from origin is acceptable.

Practical notes

  • Cancellation stops process execution and pending batch work; it cannot undo a Git operation that already completed.
  • DeleteMultiPackIndex, repack, garbage collection, commits, pushes, and recovery methods mutate repositories. Use the inspection methods first when caller-owned work may be present.
Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Soenneker.Git.Util:

Package Downloads
Soenneker.Managers.HashSaving

Handles hashing and saving

Soenneker.OpenApi.Merger

Merges OpenAPI documents with namespaced paths, components, and operation identifiers

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.3901 2,254 11/11/2026
11.0.3900 107 11/11/2026
11.0.3898 107 11/11/2026
11.0.3897 57 11/11/2026
11.0.3896 1,037 11/11/2026
11.0.3895 166 11/11/2026
11.0.3893 581 11/11/2026
11.0.3891 385 11/11/2026
11.0.3888 53 11/11/2026
11.0.3886 841 11/11/2026
11.0.3884 81 11/11/2026
11.0.3883 992 11/10/2026
11.0.3882 2,979 11/9/2026
11.0.3881 5,377 11/3/2026
11.0.3880 303 11/3/2026
11.0.3879 666 11/3/2026
11.0.3878 200 11/3/2026
11.0.3876 273 11/3/2026
11.0.3875 1,154 11/3/2026
11.0.3874 6,366 10/29/2026
Loading failed

Updated Soenneker.Utils.Paths.Resources to 11.0.318