[英]OutputDataReceived does not work with windows git.exe
我確實有一個奇怪的問題:我嘗試通過小c#console-application->調用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密碼)的存儲庫時,不會觸發任何事件,因此我無法以編程方式對此輸入做出反應。 有沒有一種方法可以真正獲得ALL命令的輸出?
謝謝!
為什么要以編程方式輸入密碼? 您可以嘗試在Git存儲庫URL中寫密碼,如下所示:
git clone https://username:password@github.com/username/repository.git
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.