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
  2. ctrl-f for the substring → [copy]
  3. git checkout -b [paste]
  • 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

--

--

--

Infrastructure Support Engineer/Technical Writer (Snowplow Analytics) with a passion for Python/writing documentation. More about me: https://pavol.kutaj.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Snyk, from first check to leader in dev-friendly open source security

Introduction to Ruby and RSpec…

Prmovi App — Watch Free Movies & TV Shows Online | Prmovies APK for Android

Thoughts about [non-]regression testing (and why I used it in a PR for scikit-learn)

3 Hot Tips for Working With Legacy Code

Implementing Dark Mode in Android App

Why DevOps Engineers so Obsessed with Kubernetes, and so are we?

Use Sequelize and Typescript like a pro! With/out the LEGACY decorators

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pavol Kutaj

Pavol Kutaj

Infrastructure Support Engineer/Technical Writer (Snowplow Analytics) with a passion for Python/writing documentation. More about me: https://pavol.kutaj.com

More from Medium

Force merge in Git

oracle vault in c#, .net, javascript, java , plsql, ruby, typescript & any domain

5 Unpopular yet useful git commands