Skip to content
Justice Tech School

The Reflog Safety Net

The reflog lists where HEAD has been, so you can recover from resets.

Example
echo one > a.txt && git add a.txt && git commit -qm 'first'
echo two >> a.txt && git commit -qam 'second'
git reset -q --hard HEAD~1
git reflog --format=%gs | head -n 3 | cut -c1-12

Result

reset: movin
commit: seco
commit (init

Exercise

List movements.

git 

Quiz Test

What does reflog record?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.