首页 > 解决方案 > ASP.NET MVC Git Pull 对我不起作用

问题描述

我想使用 c# 子进程从 git repo 中提取最新推送。我尝试的是:

它从我的 repo 中得到了最新的推送,而不是从远程 repo 中提取新的更改,我做错了什么(“获取和拉取不工作,但努力重置工作”)

            Process process = new Process();
            process = GetProcess("reset --hard");
            process.Start();               
            process.WaitForExit();

            process = GetProcess("fetch origin");
            process.Start(); 
            while (process.StandardOutput.Peek() >= 0)
            {
                ViewBag.text+= process.StandardOutput.ReadLine();
            }
            process.WaitForExit();

            process = GetProcess("checkout -B \"" + branchname + "\" 
             \"origin/" + branchname + "\" ");
            process.Start();
            while (process.StandardOutput.Peek() >= 0)
            {
                ViewBag.text+= process.StandardOutput.ReadLine();
            }

            process.WaitForExit();
            process = GetProcess("pull --progress origin");
            process.Start();
            while (process.StandardOutput.Peek() >= 0)
            {
                ViewBag.text+= process.StandardOutput.ReadLine();
            }
            process.WaitForExit();

 public Process GetProcess(string arg)
    {
        ProcessStartInfo startInfo = new ProcessStartInfo("git.exe");
        startInfo.UseShellExecute = false;
        startInfo.WorkingDirectory = projectPath;
        startInfo.RedirectStandardInput = true;
        startInfo.RedirectStandardOutput = true;

        Process process = new Process();
        process.StartInfo = startInfo;

        startInfo.Arguments = arg;
        return process;
    }

标签: c#asp.net-mvcgit

解决方案


推荐阅读