Reputation: 3454
I always have to go to a specific repository, click the switch branch button, type my branch name and finally arrive at what I want. Is there a way to submit advanced search terms into the search bar and return only my branches (the ones that I contributed to?)
Upvotes: 16
Views: 18296
Reputation: 614
Just came across this requirement myself. For the PowerShell savvy who want to see all their branches (not just those on a single repo) - here's the query I wrote to achieve this (outputs a formatted list of RepoName
and BranchName
):
# Your GitHub organisation/owner
$OrgName = "<Your organisation here>";
# Your GitHub PAT token
$PATToken = "<Your PAT token here>";
# Number of pages of repos you have
$NumberOfPages = 10;
1..$NumberOfPages | %{
curl -s -H "Accept: application/json" -H "Authorization: Bearer $PATToken" https://api.github.com/orgs/$OrgName/repos?page=$_ | ConvertFrom-Json
} | %{
$Name = $_.name; curl -s -H "Accept: application/json" -H "Authorization: Bearer $PATToken" https://api.github.com/repos/$OrgName/$Name/branches | ConvertFrom-Json | %{
[PSCustomObject]@{
RepoName = $Name;
BranchName = $_.name
}
}
}
n.b. GitHub paginates the response from the first API call, hence the input range with a higher limit of $NumberOfPages
. It seemingly doesn't matter if this value exceeds the actual number of pages of repos you have, although it will make the query run for longer so worth trying to find out how many repos you are expecting in total!
Upvotes: 0
Reputation: 2679
If your working in a organization's repository
github.com/organization/yourrepository/branches/yours
else follow @vmrvictor answer
Upvotes: 1
Reputation: 215
I would also like to point out that there is a graphical way to accomplish what is answered already here.
From https://help.github.com/articles/viewing-branches-in-your-repository/ :
On GitHub, navigate to the main page of the repository.
Above the list of files, click NUMBER branches.
Use the navigation at the top of the page to view specific lists of branches:
- Your branches: In repositories that you have push access to, the Yours view shows all branches that you’ve pushed to, with the most recent branches first.
Upvotes: 3
Reputation: 723
have you tried to use
github.com/yourrepository/branches/yours
It works in my projects but I do not know if somebody have done that
Upvotes: 10
Reputation: 535
I am not aware of a way to do this. While this is not definitive, my initial search of the help on github suggests that it's not currently possible. Based on this link: https://help.github.com/articles/searching-code/
Only the default branch is considered. In most cases, this will be the master branch.
Also, there's nothing about branches on the advanced search page, sad to say: https://help.github.com/articles/advanced-search/
Upvotes: 2