C# OutputDataReceived不适用于windows git.exe

C# OutputDataReceived不适用于windows git.exe,c#,.net,console,C#,.net,Console,我确实有一个奇怪的问题:我试图通过一个小型c#控制台应用程序调用git.exe来克隆存储库-> Process p = new Process(); p.StartInfo.FileName = "path/to/git/git.exe"; p.StartInfo.Arguments = "clone SomeGitRepoWhichRequiresPassword"; p.StartInfo.UseShellExecute = false; p.EnableRaisingEvents = tr

我确实有一个奇怪的问题:我试图通过一个小型c#控制台应用程序调用git.exe来克隆存储库->

Process p = new Process();
p.StartInfo.FileName = "path/to/git/git.exe";
p.StartInfo.Arguments = "clone SomeGitRepoWhichRequiresPassword";
p.StartInfo.UseShellExecute = false;
p.EnableRaisingEvents = true;

p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardError = true;

p.OutputDataReceived += OutputDataReceived;
p.ErrorDataReceived += ErrorDataReceived;
p.Exited += Exited;

p.Start();
p.BeginOutputReadLine();
p.BeginErrorReadLine();
p.WaitForExit();
当我尝试克隆需要用户输入(例如输入ssh密码)的存储库时,不会触发任何事件,因此我无法以编程方式对该输入做出反应。有没有办法真正获得所有命令输出


谢谢

为什么要以编程方式输入密码?您可以尝试在Git存储库URL中写入密码,如下所示:

git clone https://username:password@github.com/username/repository.git

谢谢你的回答。但是通过ssh克隆回购协议呢?有些repo只能通过ssh访问……我认为以编程方式使用git存储库的更好方法是libgit2()