c# - 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;
}
解决方案
推荐阅读
- css - 仅在悬停禁用按钮时关闭阴影
- python - pip 包不适用于新用户
- php - TYPO3 TCA selectMultipleSideBySide 删除可用项目
- java - 是否可以在启动或编译时在 Spring Boot Stream Kafka 中设置 groupId?
- python - 带有变量的烧瓶 postgres 动态查询字符串
- c# - iTextSharp- 在文本上绘制矩形
- go - 在 golang 中正确映射 YAML 配置文件
- python - 如何更改 argparse 中 nargs=* 的元变量值?
- python - 如何从扫描仪获取价值而不在屏幕上打印
- polymer - 在构造函数中初始化的对象与属性之间有什么区别