GitStore 1.18.0
dotnet add package GitStore --version 1.18.0
NuGet\Install-Package GitStore -Version 1.18.0
<PackageReference Include="GitStore" Version="1.18.0" />
<PackageVersion Include="GitStore" Version="1.18.0" />
<PackageReference Include="GitStore" />
paket add GitStore --version 1.18.0
#r "nuget: GitStore, 1.18.0"
#:package GitStore@1.18.0
#addin nuget:?package=GitStore&version=1.18.0
#tool nuget:?package=GitStore&version=1.18.0
GitStore
A .NET library that leverages Git repositories as a data store.
Note: This is not a replacement for Git operations. It only implements git clone and git push. The basic concept is to clone a remote Git repository locally, store data as text or binary files, commit the changes, and push them to the remote repository. The core operations are file reads and writes.
Usage
Install from NuGet:
dotnet add package GitStore
This library supports .NET 8 and later versions.
Basic Usage
Provide the required option parameters manually:
var option = new GitStoreOption
{
Branch = "unit-test",
Author = "test_committer",
Password = "",
CommitterEmail = "test_committer@test.com",
UserName = "<Personal Access Token>",
LocalDirectory = Path.Combine(Path.GetTempPath(), "gitstore_unittest"),
RemoteGitUrl = "https://github.com/JerryBian/gitstore-dotnet"
};
var store = new GitStore(Options.Create(option));
await store.PullFromRemoteAsync();
var content = await store.GetTextAsync(Path.Combine(option.LocalDirectory, "dummy.txt"));
Assert.Equal("test", content);
var path1 = Path.Combine(option.LocalDirectory, "data", Path.GetRandomFileName());
var content1 = Guid.NewGuid().ToString();
await store.InsertOrUpdateAsync(path1, content1);
var path2 = Path.Combine(option.LocalDirectory, "data", Path.GetRandomFileName());
var content2 = Guid.NewGuid().ToByteArray();
await store.InsertOrUpdateAsync(path2, content2);
await store.PushToRemoteAsync("commit by GitStore.");
await store.PullFromRemoteAsync();
Assert.Equal(File.ReadAllText(path1), content1);
Assert.True(content2.SequenceEqual(File.ReadAllBytes(path2)));
For GitHub repositories, you can request a Personal Access Token (PAT) here. Please note that you cannot use the traditional username/password method to operate on GitHub anymore. See the announcement for more details.
Dependency Injection / Options Pattern
For modern applications, you can register GitStore via dependency injection:
var builder = Host.CreateApplicationBuilder();
builder.Services.AddGitStore();
using IHost host = builder.Build();
var store = host.Services.GetRequiredService<IGitStore>();
var option = host.Services.GetRequiredService<IOptions<GitStoreOption>>().Value;
await store.PullFromRemoteAsync();
The option parameters are configured using the standard configuration pattern.
For example, set an environment variable as GitStore__Branch=master.
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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.31.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Options (>= 10.0.1)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.1)
-
net8.0
- LibGit2Sharp (>= 0.31.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Options (>= 10.0.1)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.1)
-
net9.0
- LibGit2Sharp (>= 0.31.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Options (>= 10.0.1)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.1)
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 |
|---|---|---|
| 1.18.0 | 136 | 1/7/2026 |
| 1.15.0 | 89 | 1/7/2026 |
| 1.5.0 | 185 | 12/5/2025 |
| 1.4.0 | 1,567 | 11/24/2023 |
| 1.3.0 | 330 | 10/22/2023 |
| 1.2.1 | 237 | 10/17/2023 |
| 1.2.0 | 205 | 10/17/2023 |
| 1.1.0 | 226 | 10/14/2023 |
| 1.0.0 | 284 | 10/14/2023 |
| 0.9.0 | 226 | 10/13/2023 |
| 0.2.1-alpha | 177 | 10/13/2023 |
| 0.2.0 | 216 | 10/13/2023 |
| 0.1.6-alpha | 187 | 10/10/2023 |
| 0.1.1-alpha | 177 | 10/10/2023 |
| 0.1.0-alpha | 177 | 10/10/2023 |