I accidentally deleted some of the origin
branches using github desktop, but not sure what are the deleted branches to restore. Is there a way to find the deleted branches, either through github desktop or through github website?
Asked
Active
Viewed 2,064 times
0

Jonathan Hall
- 75,165
- 16
- 143
- 189

gokublack
- 1,260
- 2
- 15
- 36
-
`git fetch origin`? – joanis Jan 26 '22 at 13:59
-
nope... those branches are not in remote too – gokublack Jan 26 '22 at 14:19
-
Oh. Darn. Does `git reflog` still contain the references? – joanis Jan 26 '22 at 14:21
-
nope... it doesn't show those infor – gokublack Jan 26 '22 at 14:23
-
Then you might be hooped. Once a branch is deleted, it's gone as far as I know. The commits might still exist in your sandbox if garbage collection hasn't happened, but if `git reflog` is not helping I don't know how you'd find them. My next suggestion would be to look for backups, or another developer with a sandbox that hasn't been updated since the branches were deleted. Good luck! – joanis Jan 26 '22 at 14:33
-
1This might help: [gitHub Desktop view Executed Command](https://stackoverflow.com/questions/59330552/github-desktop-view-executed-command) – TTT Jan 26 '22 at 15:09
-
1Also, if another copy of the repo somewhere has those branches and hasn't fetched yet (perhaps a co-worker or another machine), you could look at their repo to see what they have that you don't. And, if they have pruning on, if they fetch from the command line you'll see a list of branches that *you* deleted in their ourput. – TTT Jan 26 '22 at 15:14
-
1@TTT Thanks `gitHub Desktop view Executed Command` helped me to find the branches I deleted... – gokublack Jan 26 '22 at 15:55
-
@gokublack great. In that case I made it an answer. – TTT Jan 26 '22 at 18:07
2 Answers
1
In a word, no.
A branch is just a name. Once deleted, that name is deleted forever.
If you can find the commit that used to have a name, you can give it a name again. But you cannot "find deleted branches"; they are, by definition, deleted.

matt
- 515,959
- 87
- 875
- 1,141
1
There are 2 possibilities that may work for you:
Since you happen to be using GitHub Desktop, you could check the logs.
If you can access another copy of the repo somewhere that still has those branches and hasn't fetched yet since you deleted them (perhaps a co-worker or another machine), you could look at that repo to see which branches it still has that you don't. And, if they have pruning on, if they fetch from the command line you'll see a list of branches that you deleted in their output.

TTT
- 22,611
- 8
- 63
- 69