How can I pull (maybe push too) some folder from GitHub?
I mean I need API for .NET to access within C#, not GUI for git.
Open an existing Git repository. If your code is already on your machine, you can open it by using File > Open > Project/Solution (or Folder) and Visual Studio automatically detects if it has an initialized Git repository.
From the Visual Studio View menu, open Team Explorer or use the Ctrl+, Ctrl+M hotkey. Team Explorer and the Git command-line work great together.
Git is a free and open source distributed. version control system designed to handle. everything from small to very large projects. with speed and efficiency. Created by Linux creator, Linus Torvalds.
What I have done is however to write a simple class libray to call git commands by running child process.
First, create a ProcessStartInfo for some configuration.
ProcessStartInfo gitInfo = new ProcessStartInfo();
gitInfo.CreateNoWindow = true;
gitInfo.RedirectStandardError = true;
gitInfo.RedirectStandardOutput = true;
gitInfo.FileName = YOUR_GIT_INSTALLED_DIRECTORY + @"\bin\git.exe";
Then create a Process to actually run the command.
Process gitProcess = new Process();
gitInfo.Arguments = YOUR_GIT_COMMAND; // such as "fetch orign"
gitInfo.WorkingDirectory = YOUR_GIT_REPOSITORY_PATH;
gitProcess.StartInfo = gitInfo;
gitProcess.Start();
string stderr_str = gitProcess.StandardError.ReadToEnd(); // pick up STDERR
string stdout_str = gitProcess.StandardOutput.ReadToEnd(); // pick up STDOUT
gitProcess.WaitForExit();
gitProcess.Close();
It is then up to you to call whatever command now.
As James Manning mentioned in a comment in the currently accepted answer, the library libgit2sharp is an actively supported project providing a .NET API for Git.
I just found this: http://www.eqqon.com/index.php/GitSharp
GitSharp is an implementation of Git for the Dot.Net Framework and Mono. It is aimed to be fully compatible to the original Git and shall be a light weight library for cool applications that are based on Git as their object database or are reading or manipulating repositories in some way...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With