I am trying to search some code in a branch in a GitHub repository.
However this indicates that I can only search the default branch.
Is there a way I can search code in non-default branch in my GitHub repository?
I am trying to search some code in a branch in a GitHub repository.
However this indicates that I can only search the default branch.
Is there a way I can search code in non-default branch in my GitHub repository?
Not from the GitHub web interface itself, as mentioned in "How can I search for a commit message on GitHub?": only the default branch (generally master
) is indexed.
Your best bet is to clone the repository, and there, search in all branches (with git log -S
for instance).
master
, it does indexation on the DEFAULT branch which could be a release branch behind master/devel branch... –
Retrieval If you want to search in a specific branch, first set the branch by selecting it on the project main page. Then, hit the period (.
) key on your keyboard. This will open up the project in an online VS Code editor.
From there, you can use the sidebar on the left to search code or view files directly. Preferably using the Search (magnifying glass-icon) functionality to search across the whole project.
More details on GitHub Codespaces and using the web-based editor can be found here.
github.com/...
, it's github.someCorpName.com
) –
Ovariectomy Using console, I would search for specific code in a specific branch with the following
git grep 'my_search_text' my_branch
my_branch
should be available locallygit grep
can perform pattern matching of high complexity (see the documentation)With a GitHub account, you can use GitHub online editor (github.dev 1, hotkey: open a repo page and press .
on the keyboard) to open the branch of a repository and search for your keywords.
💡 Example: how to find "useMeta" keyword in github.com/nuxt/vue-meta next
branch?
This keyword is expected to be not in the default master
branch, but in next
branch. Here is how you can find it in the desired branch:
1 open the repo page and choose the branch. eg https://github.com/nuxt/vue-meta/tree/next
2 start GitHub online editor by press .
don't forget to log in GitHub first.
the online code editor url looks like https://github.dev/nuxt/vue-meta/tree/next
3 enter your keyword "useMeta" in the Search function on the code editor sidebar
4 check the result: this keyword exists in next
branch ✅
5 in the repo page, choose master
branch, enter online code editor by press .
, search for the keyword with Search function on the sidebar, and you see that the keyword is not found in that branch.
© 2022 - 2024 — McMap. All rights reserved.