5

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.

2PacIsAlive
  • 85
  • 2
  • 9
  • 2
    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 from these branches which are no longer needed. – 2PacIsAlive May 31 '19 at 17:51
  • 2
    Please revise to insert that clarifying information into your question body. – isherwood May 31 '19 at 17:52
  • Possible duplicate of [For how long can you restore/recover a deleted branch on GitHub?](https://stackoverflow.com/questions/17929891/for-how-long-can-you-restore-recover-a-deleted-branch-on-github) – tkruse Jun 01 '19 at 00:14

1 Answers1

3

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

git reflog

And then to revert

git checkout -b <branch> <sha>

alextechtai
  • 101
  • 2