所以使用LibGit2Sharphttps://github.com/libgit2/libgit2sharp你可以像这样穿过Twigusing(varrepo=newRepository(@"pathto.git")){foreach(varbranchinrepo.Branches){Debug.WriteLine(branch.Name);}}但是如何获取当前/事件分支? 最佳答案 Branch.IsCurrentRepositoryHead应该可以解决问题。我认为如果您不想遍历分支,Repository.Head也会做同样的