Pok*_*Pok 48
然而,我所做的是编写一个简单的类库,通过运行子进程来调用git命令.
首先,为某些配置创建ProcessStartInfo.
ProcessStartInfo gitInfo = new ProcessStartInfo();
gitInfo.CreateNoWindow = true;
gitInfo.RedirectStandardError = true;
gitInfo.RedirectStandardOutput = true;
gitInfo.FileName = YOUR_GIT_INSTALLED_DIRECTORY + @"\bin\git.exe";
Run Code Online (Sandbox Code Playgroud)
然后创建一个Process来实际运行该命令.
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();
Run Code Online (Sandbox Code Playgroud)
然后由您自己调用任何命令.
Ken*_*itt 40
正如James Manning在当前接受的答案中的评论中所提到的,库libgit2sharp是一个积极支持的项目,为Git提供.NET API.
Dan*_*ite 29
我刚刚发现了这个:http://www.eqqon.com/index.php/GitSharp
GitSharp是Dot.Net Framework和Mono 的Git实现.它旨在与原始Git完全兼容,并且应该是一个轻量级的库,用于基于Git作为其对象数据库或以某种方式读取或操作存储库的酷应用程序......
归档时间: |
|
查看次数: |
55748 次 |
最近记录: |