简体   繁体   English

从Windows批处理文件C#中执行git命令

[英]Executing git commands from windows batch file, C#

I'm trying to write small git client, I just want to use git pull and git clone commands. 我正在尝试编写小型git客户端,我只想使用git pull和git clone命令。

I'm doing this: 我正在这样做:

Process p = new Process();
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.FileName = "path to my.bat";
            p.Start();
            string output = p.StandardOutput.ReadToEnd();
            p.WaitForExit();

bat file works fine and executes simple commands but I want to execute git commands from that bat file and git is not recognized. bat文件可以正常工作并执行简单的命令,但是我想从该bat文件执行git命令,并且无法识别git。

Is there any right way to do this? 有什么正确的方法吗?

put a line in your batch file 在您的批处理文件中添加一行

path

and check that the output includes the directory containing the git.exe file. 并检查输出是否包含包含git.exe文件的目录。 if not, specify the complete path to the git.exe file. 如果没有,请指定git.exe文件的完整路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM