Find Deleted Branch With Git Reflog in Powershell

usecase

The aim of this playbook🏁 is to find the easiest way of getting the name of a branch that was deleted when you know at least a substring of that branch. In my case I have either an issue_tracker (Jira) ID — at least a conventional prefix I use for all of them.

1. steps/?

  1. (git reflog > reflog.md) | Invoke-Item → the log opens in your markdown editor
  • or even easier, a single-stepper git reflog | Select-String <issue trackerID>
git reflog | Select-String SPT
---
▶ git reflog | sls SPT-
2b90d67 HEAD@{13}: checkout: moving from SPT-1319/fix_error_handling to master # ← FOUND !!!
bc63693 HEAD@{14}: commit (merge): Merge branch 'master' into SPT-1319/fix_error_handling
7c3f045 HEAD@{16}: checkout: moving from 02.09 to SPT-1319/fix_error_handling
4a94424 HEAD@{41}: checkout: moving from SPT-1310/automate_commit_message to master
52e834f HEAD@{43}: checkout: moving from 02.10 to SPT-1310/automate_commit_message
94e1669 HEAD@{106}: checkout: moving from SPT-1202/create_sections to master
5d1dc22 HEAD@{108}: checkout: moving from master to SPT-1202/create_sections
db64cd1 HEAD@{111}: checkout: moving from SPT-1202/create_sections to master
5d1dc22 HEAD@{112}: checkout: moving from master to SPT-1202/create_sections
718ebce HEAD@{136}: checkout: moving from SPT-1202/create_sections to master
...

2. links

Technical Support Engineer of a Data Collection Platform (Snowplow Analytics)