![]() |
VOOZH | about |
dotnet add package GitDotNet --version 0.1.81-alpha
NuGet\Install-Package GitDotNet -Version 0.1.81-alpha
<PackageReference Include="GitDotNet" Version="0.1.81-alpha" />
<PackageVersion Include="GitDotNet" Version="0.1.81-alpha" />Directory.Packages.props
<PackageReference Include="GitDotNet" />Project file
paket add GitDotNet --version 0.1.81-alpha
#r "nuget: GitDotNet, 0.1.81-alpha"
#:package GitDotNet@0.1.81-alpha
#addin nuget:?package=GitDotNet&version=0.1.81-alpha&prereleaseInstall as a Cake Addin
#tool nuget:?package=GitDotNet&version=0.1.81-alpha&prereleaseInstall as a Cake Tool
GitDotNet is a .NET library designed to read Git repositories in a fully native .NET environment. It is optimized for minimal memory footprint and efficient data retrieval from repositories.
It also supports writing, but it doesn't write itself: it uses git fast-import to write objects and refs to the repository. This guarantees best writing performance, safe git data writing, and avoid having to reinvent the wheel (object compression...).
<details> <summary>Detailed status...</summary> As per high-level git features, the following is the current status of the project:
GitConnection.Create(path, isBare)connection.Branches["main"].Fetch()connection.CompareAsync("HEAD~10", "HEAD")await connection.CommitAsync("main", c => c.AddOrUpdate("test.txt", Encoding.UTF8.GetBytes("foo")), connection.CreateCommit(...))connection.GetLogAsync("HEAD~1", LogOptions.Default with { ... }), await (foreach commint in connection.Branches["fix/bug"])connection.GetAsync<BlobEntry>("1aad9b571c0b84031191ab76e06fae4ba1f981bc")connection.Index.GetEntriesAsync()connection.CommitAsync("main", c => c.AddOrUpdate("test.txt", Encoding.UTF8.GetBytes("foo")), connection.CreateCommit(...)).git/indexconnection.Config.GetProperty("user", "email")Note that the main purpose of DotNetGit is to provide high speed reading. Writing can be done through commands. </details>
To install GitDotNet, add the GitDotNet or GitDotNet.Microsoft.Extensions.DependencyInjection NuGet package to your project.
IServiceCollection using the AddGitDotNet extension method. This will inject ConnectionProvider and other required services.Objects.GetAsync method to retrieve Git objects by their hash.using Microsoft.Extensions.DependencyInjection;
using GitDotNet;
var services = new ServiceCollection()
.AddMemoryCache(o => o.SizeLimit = 10_000_000) // Each entry size is always 1
.AddGitDotNet();
var provider = services.BuildServiceProvider().GetRequiredService<GitConnectionProvider>();
using var connection = await provider("path/to/repo");
var commit = await connection.Branches["main"].Tip;
Console.WriteLine($"Commit Message: {commit.Message}");
var tree = await commit.GetTreeAsync();
| Method | Runtime | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Gen1 | Gen2 | Allocated | Alloc Ratio |
|---|---|---|---|---|---|---|---|---|---|---|---|
| GitDotNet | .NET 9.0 | 266.5 ns | 5.21 ns | 6.95 ns | 1.00 | 0.04 | 0.0243 | - | - | 464 B | 1.00 |
| GitDotNet | .NET 8.0 | 322.1 ns | 4.07 ns | 3.61 ns | 1.21 | 0.03 | 0.0243 | - | - | 464 B | 1.00 |
| LibGit2Sharp | .NET 9.0 | 23,787.7 ns | 428.43 ns | 379.79 ns | 1.00 | 0.02 | 0.1221 | 0.0305 | - | 2384 B | 1.00 |
| Method | Mean | Error | StdDev |
|---|---|---|---|
| GitDotNet | 5.404 s | 1.141 s | 0.0626 s |
| git archive -o result.zip HEAD | 7.357 s | 6.893 s | 0.3778 s |
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on GitDotNet:
| Package | Downloads |
|---|---|
|
GitDotNet.Microsoft.Extensions.DependencyInjection
Package Description |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.81-alpha | 324 | 9/17/2025 |
| 0.1.80-alpha | 136 | 9/12/2025 |
| 0.1.79-alpha | 140 | 9/12/2025 |
| 0.1.78-alpha | 158 | 9/12/2025 |
| 0.1.77-alpha | 182 | 9/8/2025 |
| 0.1.71-alpha | 180 | 8/20/2025 |
| 0.1.70-alpha | 183 | 8/19/2025 |
| 0.1.68-alpha | 150 | 8/16/2025 |
| 0.1.66-alpha | 185 | 8/14/2025 |
| 0.1.64-alpha | 184 | 8/12/2025 |
| 0.1.62-alpha | 183 | 8/11/2025 |
| 0.1.61-alpha | 171 | 8/11/2025 |
| 0.1.60-alpha | 184 | 8/11/2025 |
| 0.1.58-alpha | 170 | 8/10/2025 |
| 0.1.55-alpha | 197 | 7/27/2025 |
| 0.1.54-alpha | 143 | 7/13/2025 |
| 0.1.53-alpha | 147 | 7/13/2025 |
| 0.1.52-alpha | 159 | 7/11/2025 |
| 0.1.44-alpha | 165 | 5/4/2025 |
| 0.1.43-alpha | 220 | 4/13/2025 |