我有一個簡單的批處理文件:的Git拉問題與C#函數執行批處理文件
cd <path to my git repository>
git pull
我嘗試用下面的C#函數來執行它:
private NuGetBO.ShellCommandReturn ExecuteCommand(string path)
{
ProcessStartInfo processInfo;
Process process;
processInfo = new ProcessStartInfo(path);
processInfo.CreateNoWindow = true;
processInfo.UseShellExecute = false;
// *** Redirect the output ***
processInfo.RedirectStandardError = true;
processInfo.RedirectStandardOutput = true;
process = Process.Start(processInfo);
process.WaitForExit(5000);
// *** Read the streams ***
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
int exitCode = process.ExitCode;
process.Close();
return new NuGetBO.ShellCommandReturn { Error = error, ExitCode = exitCode, Output = output };
}
但我得到以下錯誤:
"Access is denied.\r\nfatal: Not a git repository (or any of the parent directories): .git\n"
換句話說,我試圖執行從C#我的批處理文件,沒有成功了幾個小時,但我的批處理文件WOR ks沒有任何問題,如果我在命令行中執行它。
如何讓我的C#函數工作,我應該在批處理文件或C#函數中更改哪些內容?由於
編輯:
我已經改變了批處理文件的內容如下:
cd <path to my git repository> && git pull
但我收到以下錯誤:
Access is denied.
EDIT2:
我已添加訪問該文件夾,現在我得到一個新的錯誤:
fatal: Not a git repository: "../.git/modules/myProject\n"
EDIT3:
我已經給了訪問權限,在EDIT2提到的文件夾,但現在我收到以下錯誤:
"error: unable to create directory for C:/myFolder/.git/modules/myProject/ORIG_HEAD\nfatal: Cannot lock the ref 'ORIG_HEAD'.\n"
這是一個愚蠢的(也許不是?)問題要問你:你確定的路徑是相同的100%? –
是的,我相信,但是從根本上來說,這個bug可能就在那裏,這絕不是愚蠢的做法。 –