How do you show the reflog for a repository?
Posted by BobHarris
Last Updated: July 12, 2024
The reflog (reference logs) in a Git repository records updates to the tips of branches and other references. It can be particularly useful for recovering lost commits. To view the reflog for a repository, you can use the following command in your terminal or command prompt:
git reflog
Running this command will display a list of logged actions along with their respective commit hashes, allowing you to see the history of changes made to the references in the repository. Each entry typically includes the commit SHA, a reference name (like HEAD), a message describing the action (e.g., commit, checkout, etc.), and a timestamp. If you want to see the reflog for a specific branch (e.g., main), you can specify the branch name:
git reflog show main
Additionally, you can limit the number of reflog entries displayed by adding an argument, like:
git reflog -n 10
This command will show the last 10 entries in the reflog.
Related Content