我想添加这些 git 命令的路径。
我有一个已识别的存储库路径,我想从该路径/存储库之外的函数执行这些 git 命令。
如何使用 C# 和 .net core 3.1 做到这一点?
string gitCommand = "git";
string gitAddArgument = @"checkout development";
string gitPull = @"pull";
Process.Start(gitCommand, gitAddArgument);
Process.Start(gitCommand, gitPull);
最佳答案
您需要将WorkingDirectory
设置为存储库路径。您还需要调用 WaitForExit
来同步运行这些命令。
Process.Start(new ProcessStartInfo(gitCommand, gitAddArgument)
{
WorkingDirectory = "path/to/repository"
})
.WaitForExit();
关于c# - 如何使用 C# .net Core 执行 git 命令显式给出存储库路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73994254/