首页 > 解决方案 > Retrieve a Remote's Default Branch

问题描述

Within the scope of LibGit2Sharp, is there a way to retrieve which branch is the default branch for any given remote? Eg, what branch would be checked out if I were to do a fresh clone?

A git.exe equivalent might be:

git remote show REMOTE_REPO_NAME | grep 'HEAD branch' | cut -d' ' -f5

I can't seem to find an equivalent API call from within LibGit2Sharp

标签: c#libgit2sharp

解决方案


No, there's no way to get that information from libgit2sharp as it doesn't wrap the git_remote_default_branch function from libgit2.

There is an open issue on GitHub (#1796) about adding the git_remote_default_branch function to libgit2sharp. I tried searching the libgit2sharp repository for git_remote_default_branch but that issue is the only result.


推荐阅读