使用到 Git 的 ForcePush 產生錯誤訊息
git push origin HEAD:master –force

看起來應該是權限不足
上去 Azure DevPos 找了一下設定

點選 Manage repositories

Force push (rewrite history, delete branches and tags) 設定為 Allow
PS.群組我選 Project Collection Administrators 視需求每人選的有所不同
public class CommitID
{
private static string EnvironmentVariable
{
get
{
string sPath = Environment.GetEnvironmentVariable("Path");
var result = sPath.Split(';');
for (int i = 0; i < result.Length; i++)
{
if (result[i].Contains(@"Git\cmd"))
{
sPath = result[i];
}
}
return sPath;
}
}
public static void GetCommitID()
{
string gitPath = System.IO.Path.Combine(EnvironmentVariable, "git.exe");
Console.WriteLine($"環境路徑:{gitPath}");
Process p = new Process();
p.StartInfo.FileName = gitPath;
p.StartInfo.Arguments = "rev-parse HEAD";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.OutputDataReceived += OnOutputDataReceived;
p.Start();
p.BeginOutputReadLine();
p.WaitForExit();
}
private static void OnOutputDataReceived(object sender, DataReceivedEventArgs e)
{
if (e != null && !string.IsNullOrEmpty(e.Data))
{
ID = e.Data;
Console.WriteLine(e.Data);
}
}
public static string ID { get; set; } = "";
}
```csharp
public class MyLogger : ILogger
{
public void Print(string msg, Color color)
{
Log.Print(msg, color);
}
}
```
這樣就能順眼的顯示 C# 的程式碼了,如下圖:
參考文章: 覺得 Google 的 Blogger 不太順手?透過 HTML 的 iframe 移花接木 HackMD