git reflog는 branch의 HEAD가 어디에 있었는지 — 모든 commit, checkout, reset, rebase 등 — 를 기록합니다. 사라진 것처럼 보이지만 여전히 복구 가능한 "잃어버린" commit을 복구하기 위한 안전망입니다(잘못된 reset, rebase, branch 삭제 후).
reflog란
reflog는 로컬 repo에서 HEAD(와 branch 끝)의 모든 이동을 기록합니다:
→ 모든 commit, checkout, reset, rebase, merge 등이 참조와 함께 기록됨
→ 로컬이며 어떤 branch에서도 도달할 수 없는 commit("잃어버린" 것)도 포함
→ reset/rebase로 commit을 없애도, reflog는 그것들이 어디 있었는지 기억함.
잃어버린 작업 복구하기
git reflog
git checkout def456
git branch recovered def456
git reset --hard def456
