I have a commit id, I want to check whether is it present in a branch or in which branches this commit id is present.
GitBranchStats doesn't have any properties related to commit info in
Microsoft.TeamFoundation.SourceControl.WebApi library.
Uri orgUrl = new Uri("https://example.com"); // Organization URL
String personalAccessToken = "XXXXXXXXX";
VssConnection connection = new VssConnection(orgUrl, new VssBasicCredential(string.Empty, personalAccessToken));
GitHttpClient gitClient = connection.GetClient<GitHttpClient>();
GitBranchStats branch = gitClient.GetBranchAsync("repo", "name").Result;
FYI, I am not looking for a git command, I already know this.
Edit:
It's giving exceptions in method check_whether_present_in_branches in a few cases when a branch is in any folder like below.
Exception message:
TF401175:The version descriptor <Branch: Release > could not be resolved to a version in the repository

Update:
Original Answer:
Provide a C# demo for you(I think I should have already considered all the situations):
Results: