I've tried to use the advanced search feature of Github, but when I search "specific text" repo:company/project/tree/specific_branch
it does not return the desired results. It only seems to search master branch.
The.git structure will then include all the branches done on that repository. To use a specific branch do git checkout [branch_name] If the branch exists the files will be made available locally (as just that, the current files in the project directories). git status will then show which branch is the current branch, for example:
But any GitHub repo is a Git repo. So you are free to use the power of console commands. There's a git grep command, allowing you to search for lines matching a pattern throughout the repository. Instead of remote_name/branch_to_search_in put the actual names of remote and branch. This example is based on the code from other SO question.
Perhaps using API. So far no option to search code in specific branch. See here 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.
You can either: Clone the repository, fetch all branches, and checkout to a specific branch immediately. Clone the repository and fetch only a single branch. With this, you fetch all the branches in the repository, checkout to the one you specified, and the specific branch becomes the configured local branch for git push and git pull .
I too was looking for this. but this support in not available as per github help.
Due to the complexity of searching code, there are a few restrictions on how searches are performed:
Only the default branch is considered. In most cases, this will be the master branch. Only files smaller than 384 KB are searchable. Only repositories with fewer than 500,000 files are searchable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With