2026-01-24

git reflog로 작업 복구

실수로 잃은 커밋을 찾는 reflog 흐름입니다.

Rhio Kim

Rhio Kim

CEO

#git#reflog#recovery

Page reactions

Leave a quick reaction to this shorts.

반응을 불러오는 중...

!!steps

!duration 180.0

!

_10
# 기본 reflog 출력
_10
$ git reflog
_10
1a2b3c4 (HEAD -> main) HEAD@{0}: commit: Update README
_10
5d6e7f8 HEAD@{1}: checkout: moving from dev to main

!!steps

!duration 240.0

!

_10
# HEAD의 최근 5개 항목
_10
$ git reflog show HEAD -n 5
_10
1a2b3c4 HEAD@{0}: commit: Update README
_10
5d6e7f8 HEAD@{1}: checkout: moving from dev to main
_10
8e9f0a1 HEAD@{2}: pull origin dev

!!steps

!duration 300.0

!

_10
# feature 브랜치의 reflog
_10
$ git reflog show feature
_10
5d6e7f8 feature@{0}: commit: Add login feature
_10
9h0i1j2 feature@{1}: reset: moving to HEAD~1

!!steps

!duration 180.0

!

_10
# 2일 전 로그 필터링
_10
$ git reflog --since="2 days ago"
_10
1a2b3c4 HEAD@{0}: commit: Update config

!!steps

!duration 240.0

!

_10
# 각 항목의 상세 정보 포함
_10
$ git reflog --format='%h | %gd | %gs'
_10
1a2b3c4 | HEAD@{0} | commit: Update README
_10
5d6e7f8 | HEAD@{1} | checkout: moving from dev to main

!!steps

!duration 180.0

!

_10
# reflog을 이용한 복구
_10
$ git reset --hard HEAD@{1}
_10
HEAD is now at 5d6e7f8 Add feature