Dot-Net

如何使用 LibGit2Sharp 獲取目前/活動分支?

  • October 11, 2012

所以使用 LibGit2Sharp <https://github.com/libgit2/libgit2sharp>你可以像這樣穿過分支

using (var repo = new Repository(@"path to .git"))
{
   foreach (var branch in repo.Branches)
   {
       Debug.WriteLine(branch.Name);   
   }
}

但是我如何獲得目前/活動分支?

Branch.IsCurrentRepositoryHead應該做的伎倆。

Repository.Head如果您不想遍歷分支,我認為也會做同樣的事情……

引用自:https://stackoverflow.com/questions/12837311