顯示具有 Git 標籤的文章。 顯示所有文章
顯示具有 Git 標籤的文章。 顯示所有文章

2019年7月26日 星期五

Azure DevPos Git 的 ForcePush 產生錯誤訊息 TF401027: You need the Git 'ForcePush' permission to perform this action. 的解決方法

最近在刪除 Git 上的敏感資料

使用到 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 視需求每人選的有所不同

2019年6月9日 星期日

Windows 10 修改 Git 憑證帳號密碼


控制台\使用者帳戶\認證管理員
CMD 上面輸入 control
可以直接呼叫「控制台」
CMD 上面輸入 control userpasswords
可以直接呼叫「使用者帳戶」







選擇要修改的憑證




修改憑證的帳號與密碼


接下來就能正常簽入了。

2019年5月29日 星期三

AWS 的 Code Commit 修改

新建使用一段時間的 Code Commit
如果想修改說明
可以點入專案 Repositories

左邊有 Settings 選項
請點擊
























進入 Settings
右邊就會列出可以修改的內容














2019年5月23日 星期四

利用 .NET Standard 函式庫 的 C# 取得 Git 版本號



這邊遇到找不到 Git 的環境變數
所以在 @"Git\cmd" 做了一些修改
這邊得看看你 Git 的執行檔在那個目錄內
再做調整與修改



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; } = "";
}


使用方法:
先呼叫 GetCommitID()
之後 ID 就會有 Git 的版本號
他會取得目前執行目錄上的 Git 版本號


























2019年5月14日 星期二

AWS 「CodeCommit」 的「Create repository」

點擊「Create repository」











填寫 Repository Name 與 Description
然後按下「Create」




























點擊 Clone URL 欄位下的 HTTPS
可以複製 Git 的 Url

2019年5月5日 星期日

一毛錢都不用花,利用 GitHub 超簡單幫你建立免費網站

首先建立一個新專案
專案名稱一定要命名為「[GitHub帳號].github.io」的格式





















[GitHub帳號] 如果是 Apple
就命名為 Apple.github.io

在專案裡新增一個 index.html 內容可以打
















上傳後,在瀏覽器打上網址:[GitHub帳號].github.io
承上例 https://apple.github.io/
就能連上網頁




如何在 GitHub 上的 README.md 寫入 C# 程式碼

GitHub 上寫 README.md 如果須要寫入 C# 程式碼範例 可以透過 ```csharp 開頭包住程式碼並用 ```做結尾 格式如下:


```csharp
public class MyLogger : ILogger
{
    public void Print(string msg, Color color)
    {
        Log.Print(msg, color);
    }
}
```



這樣就能順眼的顯示 C# 的程式碼了,如下圖:


2019年2月14日 星期四

Git GUI 中文亂碼解決方法

開啟 Edit = Option 選單

選擇 Default File Contents Encoding 為 utf-8

Save 存檔後,就正常顯示中文了。

Visual Studio 2017/2019 推薦的擴充功能與更新

參考文章: 覺得 Google 的 Blogger 不太順手?透過 HTML 的 iframe 移花接木 HackMD