Search code examples
c#gitvisual-studioazure-devops

Microsoft Azure DevOps Repo: search for text/code in specific branch


I'm embarrassed to ask what should be a simple thing to figure out....

However, when I'm viewing a specific branch in an Azure DevOps repository online (e.g., when reviewing a PR), I can't figure out how to perform a search of that branch's code.

I see a global search textbox at the top, as follows: enter image description here

And I see a textbox for searching the branch for file/folder names, as follows:

enter image description here

But what I don't see is a textbox for searching the contents of the files in that branch....e.g. for finding occurrences of someFunction() or somePropertyName or whatever inside the code files for that particular branch.

Did Microsoft really omit this functionality? Or am I missing something? How do we perform such a search?


Solution

  • First, input content in the global search textbox at the top and search:

    enter image description here

    Now, you can select your repo and branch in the dropdown lists: enter image description here

    By default, code search only applies to your default branch. You may add up to 5 more here: enter image description here Please notice that when a new branch is configured for search via “include/exclude searchable branches”, the branch list of search is not immediately populated with the newly configured branch. This happens because it takes some time to on-board a new branch and make it searchable. It takes up to 12 hours to fully initialize the branch.

    You can also refer to this document about searching your code.