简体   繁体   English

为什么此Cit从C#代码中提取不起作用

[英]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.

相关问题 从 C# 代码停止 Windows 服务不起作用 - Stopping Windows Service from C# code doesn't work 为什么我从C#到VB的转换不起作用? - Why doesn't my conversion from C# to VB work? 为什么这个C#代码没有编译? - Why doesn't this C# code compile? 从我的 C# 应用程序运行 PsList.exe 并获取其 output 的正确方法(或者为什么我的代码不起作用)? - Proper way to run PsList.exe from my C# app and get its output (Or why my code doesn't work)? 来自C#的JSLINK不起作用 - JSLINK from c# doesn't work WPF C#绑定代码-为什么这个简单的示例不起作用? - WPF C# binding code - why doesn't this simple example work? C#winforms中的静态类变量范围问题-为什么这段代码不起作用? - static class variable scope issue in C# winforms - why doesn't this bit of code work? 为什么.bat文件有效而C#代码不适用于文件夹映射 - Why .bat file works and C# code doesn't work for folder mapping 当包含“ Microsoft.WindowsAzure.Storage”时,C#的Powershell代码不起作用 - Powershell code from C# doesn't work when “Microsoft.WindowsAzure.Storage” is included 存储过程在查询生成器中执行时有效,但不适用于C#代码 - Stored procedure works when executed in query builder, but doesn't work from C# code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM