O'Reilly logo

Linux in a Nutshell, 6th Edition by Robert Love, Stephen Figgins, Ellen Siever, Arnold Robbins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

reflog

Synopsis

git reflog show [branch]

Show entries from the reflog, which tracks changes to local refs (branches). If branch is omitted, shows the reflog for HEAD.

The reflog tracks the “history of history.” Although commands like git reset can be used to undo a commit, the old commit still stays around in the reflog until it eventually expires. This allows you to undo many Git operations you might have performed by accident.

You can refer to entries in the reflog using branch@{n} notation. For example, HEAD@{5} means to use HEAD as it existed five changes ago.

Examples

To list all the recent changes to HEAD:

$ git reflog

To undo the most recent merge operation:

$ git reset HEAD@{1}

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required