[英]Why this Git pull from C# code doesn't work
I have to pull updates from C# code but it doesn't pull the updates. 我必须从C#代码中提取更新,但它不提取更新。 I tried the command line and it worked fine.
我尝试了命令行,它工作正常。
string gitCmd = "/C cd 'C:\\Users\\jean.wang\\source\\repos\\UpdateScriptRename\\vcs\\trunk' && git pull";
Process.Start("CMD.exe", gitCmd);
Your string has ''
in cd, but cmd doesn't accept the ''
as enquoting character, change them to ""
, like so: 您的字符串在cd中包含
''
,但cmd不接受''
作为引号字符,请将其更改为""
,如下所示:
"/C cd \"C:\\Users\\jean.wang\\source\\repos\\UpdateScriptRename\\vcs\\trunk\" && git pull";
or you can even just set working directory before Process.Start: 或者甚至可以在Process.Start之前设置工作目录:
string dir = "C:\\Users\\jean.wang\\source\\repos\\UpdateScriptRename\\vcs\\trun";
Process.Start(new ProcessStartInfo(){FileName = "git.exe", Arguments = "pull", WorkingDirectory = dir});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.