Suggest an editImprove this articleRefine the answer for “What is reflog and why is it needed?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)**`git reflog`** is a log of the movements of the HEAD pointer and branches in the local repository. **Key point:** reflog is an "insurance policy" against losing history in the local repository, letting you recover commits after reset, rebase, and other dangerous operations.Shown above the full answer for quick recall.Answer (EN)Image`git reflog` is a log of the movements of the **HEAD** pointer and branches in the local repository. It stores information about: - where HEAD pointed - which commands changed the repository's state - which commits were current before --- ## Why reflog is needed `reflog` lets you: - recover commits after a `reset` - find lost commits after a `rebase` - return to the state before a mistaken command - recover work after a `checkout` or `commit --amend` Its main purpose: > reflog is an "insurance policy" against losing history in the local repository. --- ## What is important to know - `reflog` is **local** - it is not transferred via `push` - it is kept for a limited time (by default ~90 days) - it contains even commits that are no longer reachable via `git log` --- ## Example usage ```bash git reflog ``` The output shows the list of HEAD states: ```text HEAD@{0} reset: moving to HEAD~1 HEAD@{1} commit: add feature ``` You can return to a state: ```bash git checkout HEAD@{1} ``` or ```bash git reset --hard HEAD@{1} ``` --- ## A key phrasing for an interview > `git reflog` is a local log of HEAD changes that lets you recover commits and the repository's state after reset, rebase, and other dangerous operations.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.