Git Refs and Reflogs (original) (raw)

Last Updated : 16 Jan, 2026

Refs and reflogs in Git help track branch pointers and record updates to references, making it possible to recover lost commits.

Types of Refs

Viewing Refs in a Git Repository

Refs are stored as plain text files inside the .git/refs directory. You can explore them by navigating to .git/refs or by running a Git command from the project’s root directory.

$ ls -F1 .git/refs

or type the command in Git bash in the root directory of your project

find .git/refs

You should see the following structure, but it will contain different files depending on what branches, tags and remotes you have in your repo.

$ ls -F1 .git/refs ├── heads/ │ └── master ├── remotes/ ├── tags/

Git Reflogs

A reflog (reference log) records when the tips of branches and other refs were updated in your local repository. Every time you:

Git logs the movement of that reference into the reflog.

For example, Head@{2} points to where HEAD was two updates ago.

git reflog HEAD@{2}

If you want to inspect the commit itself, use:

git show HEAD@{2}

Command that manages information recorded in reflogs:

git reflog

Common Git Reflog Commands

Git reflog commands come with various subcommands for advanced usage:

git reflog [show] [log-options] [] git reflog expire [--expire=

Words in square brackets such as "show", "log-options" are qualifiers, or we can say arguments to git reflog command.

Whether you are fixing mistakes or just understanding what happened, mastering refs and reflogs can make you much more confident using Git.