Skip to content

Instantly share code, notes, and snippets.

@idiotandrobot
Created June 26, 2023 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idiotandrobot/e6bce99f6c5ed5b3f4aa5d61e31ba7e3 to your computer and use it in GitHub Desktop.
Save idiotandrobot/e6bce99f6c5ed5b3f4aa5d61e31ba7e3 to your computer and use it in GitHub Desktop.
string directory = ""; // directory of the git repository
using (PowerShell powershell = PowerShell.Create()) {
// this changes from the user folder that PowerShell starts up with to your git repository
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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment