HansPeterGit 0.1.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package HansPeterGit --version 0.1.6
NuGet\Install-Package HansPeterGit -Version 0.1.6
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="HansPeterGit" Version="0.1.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HansPeterGit --version 0.1.6
#r "nuget: HansPeterGit, 0.1.6"
#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.
// Install HansPeterGit as a Cake Addin
#addin nuget:?package=HansPeterGit&version=0.1.6

// Install HansPeterGit as a Cake Tool
#tool nuget:?package=HansPeterGit&version=0.1.6

HansPeterGit

NuGet License Build Status

Maintainability Rating Reliability Rating Security Rating Bugs Vulnerabilities Coverage

GIT interface for .NET

This repository contains a cross-platform interface to the git CLI (aka git.exe/git).

The project aim is to get rid of the stale library libgit2sharp and provide an easy interface to interact with the git cli.

Dependencies

An installed version of git should be accessible via path.

Install

Add the NuGet package HansPeterGit to any project supporting .NET Standard 2.0 or higher.

> dotnet add package HansPeterGit

Usage

Clone a repository

GitRepository.Clone() can download a remote repository to the local file system, same as the git clone command.

GitRepository.Clone("https://github.com/twenzel/HansPeterGit.git", @"D:\TestSample");

Create a local repository

The GitRepository.Init() method can create a new Git repository in the specified path, equivalent to the git init command.

var repos = new GitRepository(@"D:\TestSample");
repos.Init();

Get status

Using the GetStatus() method to retrieve the repositories current status.

var repos = new GitRepository(@"D:\TestSample");
var status = repos.GetStatus();

Console.WriteLine($"Current branch: {status.Branch}");
Console.WriteLine($"Current commit: {status.Commit}");

if (status.IsDirty)
{
    var newfile = status.Added.First();
}

var fileInfo = status["src/newFile.json"];

Staging/Restore

To stage the current work tree use any of the Stage/Add/Restore methods.

repos.StageAll();

// Stage file
repos.Add("src/newFile.json");

// Discard changes in working directory
repos.Restore("src/newFile.json");

// Unstage file
repos.Unstage("src/newFile.json");

Commit changes

The Commit() method can be used to commit the current changes.

var commit = repos.Commit("Fix calculation bug");

// with dedicated author
repos.Commit("Fix calculation bug", new Author("Some name", "bugfixer@test.com"));

Push changes

To push changes from the local repository please use the Push() methods.

repos.Push();

// with dedicated remove name
repos.Push("origin", "main");

// with setting an upstream
repos.PushWithUpstream("origin", "main");

Others

There are already some other methods but not all commands are wrapped/implemented yet. Please feel free to create an issue or contribute.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
0.1.12 110 1/22/2024
0.1.10 383 9/12/2022
0.1.9 401 7/20/2022
0.1.8 375 7/20/2022
0.1.7 364 7/20/2022
0.1.6 379 7/20/2022
0.1.3 378 7/19/2022
0.1.2 376 7/19/2022