- 01Getting Started
- 02What Is Git? Understanding Version Control
- 03Checking the Current State with git status
- 04Understanding the "Staging Area"
- 05Recording Changes with git commit
- 06Viewing History with git log
- 07Viewing Changes with git diff
- 08What Is a Branch?
- 09Switching Branches with git checkout
- 10Merging Branches with git merge
- 11Remote Repositories and git remote
- 12Sending Changes with git push
- 13Getting Code with git pull and git clone
- 14Shelving Work Temporarily with git stash
- 15Marking Releases with git tag
- 16Unstaging with git reset
- 17Untracking a File with git rm
- 18Ignoring Files with .gitignore
- 19Deleting a Branch with git branch -d
- 20Setting Your Name with git config
- 21Viewing the Latest Commit with git show
- 22Fetching Remote Info Only with git fetch
- 23Viewing History Compactly with git log --oneline
- 24Finding Who Changed a File with git blame
- 25Undoing a Commit with git revert
- 26Fixing the Last Commit with git commit --amend
- 27Viewing the Staged Diff with git diff --staged
- 28Visualizing History with git log --graph
- 29Switching Branches with git switch (the Newer Syntax)
- 30Renaming a Branch with git branch -m
- 31Filtering History by Author with git log --author
- 32Deleting a Stash with git stash drop
- 33Deleting a Tag with git tag -d
- 34Listing Remotes with git remote -v
- 35Replaying Your Branch with git rebase
- 36Viewing Changed Files Alongside History with git log --stat
- 37Staging and Committing Together with git commit -a
- 38Discarding File Changes with git checkout --
- 39Picking Just One Commit with git cherry-pick
- 40Recording a Rename with git mv
- 41Checking HEAD's Movement History with git reflog
- 42Applying a Stash Without Removing It with git stash apply
- 43Creating an Annotated Tag with git tag -a
- 44Filtering History by Date with git log --since
- 45Viewing the Actual Changes with git log -p
- 46Getting Just the Current Branch Name with git branch --show-current
- 47Creating an Empty Commit with git commit --allow-empty
- 48Searching Commit Messages with git log --grep
- 49Removing a Remote with git remote remove
- 50Understanding the Danger of git push --force
- 51Counting Commits per Author with git shortlog
- 52Returning to Your Previous Branch with git switch -
- 53Viewing One File's Diff with git diff <file>
- 54Listing Your Settings with git config --list
- 55Checking Status Compactly with git status -s
- 56Adding Only Changes with git commit --amend --no-edit
- 57Mastering the git commit -am Shorthand
- 58Adding a Message to a Stash with git stash push -m
- 59Searching Tags by Pattern with git tag -l
Checking HEAD's Movement History with git reflog
This lesson covers checking HEAD's movement history with git reflog. It's for anyone searching "git reflog usage."
git reflog shows a behind-the-scenes history of how HEAD (your current position) has moved, which doesn't appear in a regular git log. It's your last resort for recovering a commit you accidentally deleted.
In Try It, run git reflog. Every past operation — branch switches, resets, rebases, and more — is displayed in chronological order.
A common early mistake is not knowing reflog exists at all — even in a panic moment like "I accidentally reset and lost my commit," it's reassuring to know reflog can likely get you back to the state before it disappeared.
In real teams, reflog is a genuinely reliable recovery tool for when a history-rewriting operation like rebase or reset goes wrong.
🧑💻 You can type this command into the Git pseudo terminal to try it yourself (this page itself has no interactive terminal).
