1mike12
1mike12

Reputation: 3454

A way to show all my branches on github

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

Answers (6)

possen
possen

Reputation: 9274

You can click on the branches. Then click on yours tab.

Click on branchees

enter image description here

enter image description here

Upvotes: 1

AHowgego
AHowgego

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

Gopala Raja Naika
Gopala Raja Naika

Reputation: 2679

If your working in a organization's repository

github.com/organization/yourrepository/branches/yours

else follow @vmrvictor answer

Upvotes: 1

dadexix86
dadexix86

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/ :

  1. On GitHub, navigate to the main page of the repository.

  2. Above the list of files, click NUMBER branches.

  3. 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

vmrvictor
vmrvictor

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

mrcheshire
mrcheshire

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

Related Questions