2
votes

How can I tell if a branch exists in my vsts git repo using the REST API?

I see there's a ref endpoint, and I can filter the query for heads(branches) only, but how can I specific a branch name filter? Pulling back all the branch names and filtering on the client isn't a great answer.

I didn't find anything in the API docs at https://www.visualstudio.com/en-us/docs/integrate/api/git/refs#just-branches

1

1 Answers

2
votes

The documentation tells you:

filter Git ref name filter. If you specify this parameter, only refs that start with that string are returned.

So if you want to get the branch develop exists, you filter on refs/heads/develop.