Git reflog
Definition
Git Reflog records locally how branch and other reference states have changed.
A Git Reflog logs updates of local references, for example the previous states of a branch or of HEAD. This allows earlier positions to be traced. The log is local, can lose entries, and is not a permanently guaranteed complete project backup.
Simply explained
You can check where a version pointer previously pointed, even if the current branch history looks different.
Why it matters in practice
This helps investigate accidental branch movements and can make a still existing earlier commit findable again.
Example from business
Possible example: After an unwanted rebase, a developer searches the reflog for the previous state and saves it in an additional branch.
Limits and pitfalls
- Reflog entries apply to the respective repository and have limited retention. Objects already removed cannot be reliably restored solely by an old reference.
Origin & history
Reflogs complement the commit history by tracking movements of the pointers to this history. Thus, they document local work steps that a normal commit history does not immediately show.
Use in mid-sized companies
- A team uses reflog for targeted recovery and creates regular references as well as suitable independent backups for permanently important states.
Frequently asked questions
Is the reflog the same on all machines?
No. It is created locally from the reference changes of the respective repository and is not synchronized like branch commits.
Sources
- git-reflog. · Git-Projekt (o. J.): git-reflog.
Editorially reviewed on: