GitStore 1.18.0

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

GitStore

A .NET library that leverages Git repositories as a data store.

master

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

MIT

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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