开发者

Is there some way to work with git using .NET application? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

Closed 8 years ago.

Improve this question

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.


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.


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.


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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜