Git Restore With Reflog

usecase

The aim of this how-to-guide🏁 is to show the restore of data of for example a deleted commit via git reflog.

  • reflog stands for REFERENCE LOGS
  • record when the tips of branches and other references were updated in the LOCAL REPO

1. Instructions

  • Run git reflog
  • Run git checkout -b <recoverBranch> <sha>
  • the name of the <recoverBranch> is IRRELEVANT & CUSTOM
  • the sha is CRUCIAL & FIXED
  • you may have to commit/stash all changes in the working area before creating a detached head
  • e.g. git checkout -b restoreTests 284270a
  • Recover data by placing them somewhere else
  • Return to master by git checkout master
  • Delete the ad-hoc branch by git branch -D <recoverBranch>

2. sources

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

Don’t let your dynamic DAGs disturb Airflow

Deploying and managing data-centric confidential applications in the cloud with EdgelessDB and…

Integrating Github and Jenkins using Docker:Automating the flow(CI/CD)-2

Async Booking System

Journal 130 — Unity App Development, AWS Setup Part 2

JAVA Floating Point Number’s Rounding Problem & Solution

How to Create a Dating App Like Tinder: Full Guide

How to Install Apache Web Server on CentOS8 Project

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

Squashing commits with Git interactive rebase

AWS IoT With .NET Core (MQTT)

Backup and Restore SQLite database (.db) using C# .NET

Object Cloning Distilled A.K.A Correct way to work with Prototype Pattern in C#