I understand this is an old question, but I wanted to add a solution that I recently came across to help them in the future.
PowerShell git. System.Management.Automation .NET. , System.Management.Automation.dll NuGet.
string directory = "";
using (PowerShell powershell = PowerShell.Create()) {
powershell.AddScript($"cd {directory}");
powershell.AddScript(@"git init");
powershell.AddScript(@"git add *");
powershell.AddScript(@"git commit -m 'git commit from PowerShell in C#'");
powershell.AddScript(@"git push");
Collection<PSObject> results = powershell.Invoke();
}
, , Process.Start(). , , powershell.
@ArtemIllarionov, powershell.Invoke() , Streams . powerShell.Streams.Error .