简体   繁体   中英

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.

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.

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. if not, specify the complete path to the git.exe file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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