CodeLogic.GitHelper
4.5.2-preview.68
See the version list below for details.
dotnet add package CodeLogic.GitHelper --version 4.5.2-preview.68
NuGet\Install-Package CodeLogic.GitHelper -Version 4.5.2-preview.68
<PackageReference Include="CodeLogic.GitHelper" Version="4.5.2-preview.68" />
<PackageVersion Include="CodeLogic.GitHelper" Version="4.5.2-preview.68" />
<PackageReference Include="CodeLogic.GitHelper" />
paket add CodeLogic.GitHelper --version 4.5.2-preview.68
#r "nuget: CodeLogic.GitHelper, 4.5.2-preview.68"
#:package CodeLogic.GitHelper@4.5.2-preview.68
#addin nuget:?package=CodeLogic.GitHelper&version=4.5.2-preview.68&prerelease
#tool nuget:?package=CodeLogic.GitHelper&version=4.5.2-preview.68&prerelease
CodeLogic.GitHelper
Git repository management library for CodeLogic applications, powered by LibGit2Sharp.
Install
dotnet add package CodeLogic.GitHelper
Quick Start
var gitLib = new GitHelperLibrary();
// After library initialization via CodeLogic framework:
var repo = await gitLib.GetRepositoryAsync("Default");
var info = await repo.GetRepositoryInfoAsync();
Console.WriteLine($"Branch: {info.Value!.CurrentBranch}, Dirty: {info.Value.IsDirty}");
var status = await repo.GetStatusAsync();
await repo.CommitAsync(new CommitOptions { Message = "Update config" });
Features
- Clone, fetch, pull, push — full remote workflow with HTTPS authentication
- Branch management — list, checkout, and inspect branches (local and remote)
- Commit and status — stage changes, commit with metadata, and query working-tree status
- Reset / sync helpers —
ResetHardAsyncand idempotentEnsureUpToDateAsync - Commit log — read commit history with
GetCommitLogAsync - Batch operations —
FetchAllAsync,GetAllStatusAsync, andExecuteOnAllAsyncacross all configured repositories - Repository caching — configurable in-memory cache with automatic eviction
Result handling
Every Git operation returns a GitResult<T> rather than throwing. Inspect it before
using the payload:
var result = await repo.PullAsync();
if (result.IsSuccess)
Console.WriteLine($"Pulled in {result.Diagnostics.Duration?.TotalSeconds:F2}s");
else
Console.WriteLine($"Pull failed: {result.ErrorMessage}");
IsSuccess— whether the operation succeeded.Value— the typed payload (non-null only on success).ErrorMessage/Exception— failure details.Diagnostics— timing (Duration), counters, and timestampedMessages.
Repository operations
A GitRepository exposes the full single-repo workflow. All write operations are
serialized by an internal async lock, and most accept an *Options object (with a
CancellationToken) that can be omitted for defaults.
var repo = await gitLib.GetRepositoryAsync("Default");
// Clone (fails if the local directory exists and is non-empty)
await repo.CloneAsync(new CloneOptions { BranchName = "main" });
// Fetch / pull / push
await repo.FetchAsync(new FetchOptions { Prune = true });
await repo.PullAsync();
await repo.PushAsync(new PushOptions { Force = false });
// Branches
var branches = await repo.ListBranchesAsync(includeRemote: true);
await repo.CheckoutBranchAsync("develop");
// Commit specific files
await repo.CommitAsync(new CommitOptions
{
Message = "Update config",
AuthorName = "Bot",
AuthorEmail = "bot@example.com",
FilesToStage = ["config.json"]
});
// Commit history (0 = all)
var log = await repo.GetCommitLogAsync(maxCount: 10);
foreach (var c in log.Value!)
Console.WriteLine($"{c.ShortSha} {c.ShortMessage}");
Reset and one-call sync
// Hard-reset the working tree to origin/<branch> (defaults to the tracked upstream)
await repo.ResetHardAsync("main");
// Idempotent: clones if missing, otherwise fetches + hard-resets to the remote tip.
// Branch defaults to the repository's configured DefaultBranch.
var info = await repo.EnsureUpToDateAsync();
Manager and batch operations
GetManager() returns the GitManager that owns the repository pool, runtime
registration, the cache, and cross-repository batch calls. Convenience wrappers for the
most common batch calls are also exposed directly on the library.
// Run any operation across every configured repository (bounded concurrency)
var manager = gitLib.GetManager();
var infos = await manager.ExecuteOnAllAsync(
(repo, id) => repo.GetRepositoryInfoAsync());
// Built-in batch helpers (also available on the manager)
Dictionary<string, GitResult<bool>> fetched = await gitLib.FetchAllAsync();
Dictionary<string, GitResult<RepositoryStatus>> statuses = await gitLib.GetAllStatusAsync();
// Per-repository health check (id → healthy)
Dictionary<string, bool> health = await manager.HealthCheckAsync();
Runtime registration and cache control
// Add a repository discovered after startup
gitLib.RegisterRepository(new RepositoryConfiguration
{
Id = "Docs",
RepositoryUrl = "https://github.com/org/docs.git",
LocalPath = "docs",
DefaultBranch = "main"
});
await manager.UnregisterRepositoryAsync("Docs");
// Inspect and clear the in-memory cache
CacheStats? stats = gitLib.GetCacheStats();
await gitLib.ClearCacheAsync();
Authentication
HTTPS authentication is driven by the Username / Password fields on each repository
configuration. When only Password is set (a Personal Access Token), the username is
sent as x-access-token — the placeholder GitHub accepts for PAT-only auth. Leave both
blank for anonymous access.
The SshKeyPath / SshPassphrase configuration fields are reserved for future use but
are not currently wired — the shipped LibGit2Sharp 0.30 managed binary has no native
SSH transport, so use HTTPS URLs.
Configuration
Config file: config.githelper.json
{
"Enabled": true,
"BaseDirectory": "",
"DefaultTimeoutSeconds": 300,
"MaxConcurrentOperations": 3,
"EnableRepositoryCaching": true,
"CacheTimeoutMinutes": 30,
"Repositories": [
{
"Id": "Default",
"Name": "My Repository",
"RepositoryUrl": "https://github.com/username/repository.git",
"LocalPath": "my-repo",
"DefaultBranch": "main",
"Username": null,
"Password": null,
"AutoFetch": false,
"AutoFetchIntervalMinutes": 0,
"TimeoutSeconds": 300
}
]
}
Documentation
Full API docs: https://github.com/Media2A/CodeLogic.Libs
Requirements
- .NET 10.0+
- CodeLogic 3.x or 4.x
- LibGit2Sharp 0.30+
License
MIT — see LICENSE
| 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
- CodeLogic (>= 3.2.0 && < 5.0.0)
- LibGit2Sharp (>= 0.30.0)
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.6.72 | 179 | 6/20/2026 |
| 4.6.69-preview | 32 | 6/20/2026 |
| 4.5.2 | 104 | 5/24/2026 |
| 4.5.2-preview.68 | 55 | 6/20/2026 |
| 4.5.1 | 158 | 5/24/2026 |
| 4.5.1-preview.56 | 96 | 5/24/2026 |
| 4.4.2-preview.53 | 62 | 5/24/2026 |
| 4.4.1 | 104 | 5/24/2026 |
| 4.0.5 | 104 | 5/15/2026 |
| 4.0.4 | 105 | 5/9/2026 |
| 4.0.3 | 112 | 5/9/2026 |
| 4.0.1 | 398 | 4/26/2026 |
| 3.3.1 | 614 | 4/18/2026 |
| 3.3.0 | 115 | 4/18/2026 |
| 3.2.11 | 126 | 4/18/2026 |
| 3.2.10 | 107 | 4/18/2026 |
| 3.2.9 | 112 | 4/18/2026 |
| 3.2.8 | 103 | 4/18/2026 |
| 3.2.7 | 104 | 4/18/2026 |
| 3.2.6 | 110 | 4/18/2026 |
# CL.GitHelper — Changelog
All notable changes to **CodeLogic.GitHelper** are documented here. Versions follow
[Semantic Versioning](https://semver.org/).
## [4.5.2] — 2026-06-20
### Documentation
- Documented the full `GitRepository` workflow in the README: `CloneAsync`,
`FetchAsync`, `PullAsync`, `PushAsync`, `ListBranchesAsync`, `CheckoutBranchAsync`,
`CommitAsync` (with `FilesToStage`), and `GetCommitLogAsync`.
- Documented the `ResetHardAsync` and `EnsureUpToDateAsync` sync helpers with examples.
- Documented the `GitResult<T>` return contract (`IsSuccess` / `Value` / `ErrorMessage`
/ `Diagnostics`).
- Documented `GitManager` access via `GetManager()`, including `ExecuteOnAllAsync`,
`HealthCheckAsync`, runtime `RegisterRepository` / `UnregisterRepositoryAsync`, and
cache control (`GetCacheStats`, `ClearCacheAsync`).
- Clarified authentication: PAT-only auth sends `x-access-token`, and the SSH key
configuration fields are reserved but not currently wired (use HTTPS URLs).
## [4.5.0] — 2026-05-24
### Changed
- **Unified versioning.** All CodeLogic.Libs now share a single version line
controlled by `version.txt` in the repo root. This is a version alignment
release — no functional changes to this library.
## [4.0.4] — 2026-04-16
### Changed
- README + manifest refresh for the v4 baseline. No functional changes vs 4.0.3.
- `LibraryManifest.Version` now reads from assembly metadata.
## [4.0.3] — 2026-04-15
### Added
- Wired credentials through to `Clone` / `Fetch` / `Pull` and added
`ResetHard` + `EnsureUpToDate` helpers.
## [4.0.2] — 2026-04-09
### Changed
- Annotated GitHelper configuration with `[ConfigField]` for the admin UI surface.
- Aligned with the v4 baseline across all libraries.
## [4.0.0] — 2026-04-09
Major rewrite. Republished as v4.0.0 to reset the version line under the
unified v4 baseline. Thin libgit2sharp wrapper for programmatic clone /
pull / fetch / reset.
### Notes
- Earlier history is retained in the
[git log](https://github.com/Media2A/CodeLogic.Libs/commits/main/CL.GitHelper).