0
0
Gitdevops~20 mins

Reflog for finding lost commits in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Reflog Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What does the command git reflog show?
You run git reflog in your repository. What output do you expect to see?
Git
git reflog
AA list of recent HEAD positions with commit hashes and messages.
BA list of all tags in the repository.
CThe current status of files in the working directory.
DA list of all branches and their remote tracking status.
Attempts:
2 left
💡 Hint
Think about what 'reflog' tracks in Git.
💻 Command Output
intermediate
1:30remaining
What is the output of git reflog show HEAD@{2}?
Assuming your reflog has at least 3 entries, what does this command display?
Git
git reflog show HEAD@{2}
AThe commit details of the third most recent HEAD position.
BThe current commit hash and message.
CAn error saying the reflog entry does not exist.
DA list of all commits in the repository.
Attempts:
2 left
💡 Hint
HEAD@{n} refers to the nth previous position of HEAD.
🔀 Workflow
advanced
2:30remaining
How to recover a lost commit using reflog?
You accidentally reset your branch and lost a commit. Which sequence of commands correctly recovers the lost commit using reflog?
A1,3,2,4
B1,2,3,4
C2,1,3,4
D1,4,3,2
Attempts:
2 left
💡 Hint
First find the commit, then create a branch from it.
Troubleshoot
advanced
2:00remaining
Why does git reflog not show a lost commit?
You lost a commit but git reflog does not list it. What is the most likely reason?
AThe commit is hidden because the branch was deleted.
BThe commit was never created in the repository.
CThe reflog only shows remote branch history, not local commits.
DThe reflog expired or was cleaned and no longer tracks that commit.
Attempts:
2 left
💡 Hint
Reflog entries expire after some time or cleanup.
Best Practice
expert
2:00remaining
What is the best practice to avoid losing commits that reflog might not recover?
Which option is the best practice to ensure commits are not lost even if reflog expires or is cleaned?
AUse <code>git reset --hard</code> frequently to clean history.
BRely solely on reflog to find lost commits when needed.
CRegularly push commits to a remote repository to back them up.
DDelete branches immediately after merging to keep history clean.
Attempts:
2 left
💡 Hint
Think about how to keep commits safe beyond local history.