0
0
Gitdevops~5 mins

Reflog for finding lost commits in Git - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is git reflog used for?

git reflog shows a log of where your HEAD and branches have been. It helps you find commits that seem lost or unreachable.

Click to reveal answer
beginner
How does git reflog help recover lost commits?

It records every change to HEAD, so you can find the commit hash of lost commits and restore them by checking out or resetting to that hash.

Click to reveal answer
intermediate
What command would you use to reset your branch to a lost commit found in reflog?

You use git reset --hard <commit-hash> to move your branch pointer back to the lost commit.

Click to reveal answer
beginner
True or False: git reflog only shows commits that are part of the current branch.

False. git reflog tracks all HEAD movements, including commits from other branches or detached HEAD states.

Click to reveal answer
intermediate
What is the difference between git log and git reflog?

git log shows the commit history of the current branch. git reflog shows all recent changes to HEAD, including commits that might not be in the current branch history.

Click to reveal answer
What does git reflog record?
AAll changes to HEAD and branch pointers
BOnly commits pushed to remote
COnly commits merged into main branch
DOnly uncommitted changes
Which command helps you restore a lost commit found in reflog?
Agit checkout &lt;commit-hash&gt;
Bgit push origin main
Cgit merge &lt;commit-hash&gt;
Dgit stash pop
If you want to move your branch pointer back to a lost commit, which command is best?
Agit commit --amend
Bgit reset --hard &lt;commit-hash&gt;
Cgit branch -d &lt;branch-name&gt;
Dgit fetch origin
Does git reflog show commits that are not reachable by any branch?
AOnly commits pushed to remote
BNo, only commits on branches
CYes, it tracks all HEAD movements
DOnly commits merged into main
What is the main difference between git log and git reflog?
A<code>git log</code> shows stash history; <code>git reflog</code> shows branch history
B<code>git log</code> shows uncommitted changes; <code>git reflog</code> shows commits
C<code>git log</code> shows remote commits; <code>git reflog</code> shows local commits
D<code>git log</code> shows commit history; <code>git reflog</code> shows HEAD changes
Explain how you would use git reflog to find and recover a lost commit.
Think about how reflog tracks HEAD movements and how to move your branch pointer.
You got /3 concepts.
    Describe the difference between git log and git reflog and why reflog is useful for recovering lost commits.
    Consider what each command tracks and their purpose.
    You got /3 concepts.