Search code examples
gitgithubgithub-api

How to list deleted github branches


I need a way to list deleted branches on github, so I can clean up artifacts that are no longer needed.

Using the git ls-remote --heads <my repo> command, I can list all the active branches on github, but I need a way to list the deleted branches.

Is this possible using either the git cli or the github developer api?

Edit:

To clarify, when I look at an old PR on github, I can see that it provides the option to "restore" the deleted branch, which made me think these deleted branches might be available somewhere on github. These are not local branches, they are branches that have been specifically deleted on github. And by artifacts I mean things I built using these branches which are no longer needed.


Solution

  • For what I understand you can use to see the old deleted branch

    git reflog

    And then to revert

    git checkout -b <branch> <sha>