HansPeterGit 0.1.7
See the version list below for details.
dotnet add package HansPeterGit --version 0.1.7
NuGet\Install-Package HansPeterGit -Version 0.1.7
<PackageReference Include="HansPeterGit" Version="0.1.7" />
paket add HansPeterGit --version 0.1.7
#r "nuget: HansPeterGit, 0.1.7"
// Install HansPeterGit as a Cake Addin #addin nuget:?package=HansPeterGit&version=0.1.7 // Install HansPeterGit as a Cake Tool #tool nuget:?package=HansPeterGit&version=0.1.7
HansPeterGit
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 or can be defined via the GitOptions.PathToGit
property.
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 | Versions 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. |
-
.NETStandard 2.0
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.1)
-
net6.0
- Microsoft.Extensions.Logging.Abstractions (>= 6.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.