1
votes

How to get all files in a specific branch in a GIT repository in VSTS through VSTS REST API? Our project has multiple repositories and each repository may have multiple branches, like a branch for each user story and sometimes a branch for a separate feature. The below endpoint lets me get all items from the Repository, but from which branch is this endpoint returning the list of files? How do I get the list of files from a specific branch, say for example from a branch named Feature0001

GET https://{accountName}.visualstudio.com/{project}/_apis/git/repositories/{repositoryId}/items?api-version=4.1

Please advice

1

1 Answers

2
votes

The documentation for this API mentions a versionDescriptor.version query string parameter, documented as Version string identifier (name of tag/branch, SHA1 of commit). This should work if you append &versionDescriptor.version=Feature0001 to your URI.

If you don't supply this argument, I would expect the API to return the repository's default branch (eg. master).