5 exercises — interactive rebase, cherry-pick, reflog, bisect, and stash — advanced Git vocabulary for day-to-day engineering work.
0 / 5 completed
1 / 5
During an interactive rebase (git rebase -i HEAD~4) you see the command squash next to a commit. What does it do?
In interactive rebase, each commit line gets a command: pick (keep as-is), squash (merge into previous, combine messages), fixup (merge into previous, discard this message), reword (keep changes, edit message), drop (delete commit). squash vs fixup: both collapse the commit, but fixup silently discards the message.
2 / 5
"I used git cherry-pick to bring that hotfix into the release branch." Cherry-pick means:
git cherry-pick <sha> replays a specific commit onto the current branch — useful for backporting a fix without merging a whole branch. Key flags: -n (--no-commit) applies changes without committing so you can combine with other edits; -x appends the original SHA to the commit message for traceability. Conflicts are resolved the same way as a merge.
3 / 5
"I recovered the accidental reset using git reflog." What does reflog show?
git reflog records every time HEAD moves — branch switches, commits, rebases, resets, amends. Entries expire after 90 days by default. This makes it a safety net: even after git reset --hard or a dropped rebase commit, the SHA is still in the reflog and you can restore it with git checkout <sha> or git reset --hard <sha>.
4 / 5
"A regression appeared somewhere in the last 200 commits. We used _____ to do a binary search — marking commits as good or bad — until Git isolated the exact breaking commit."
git bisect automates binary search through commit history: git bisect start, then git bisect bad (current commit is broken) and git bisect good <sha> (last known-good commit). Git checks out the midpoint; you test and mark it good or bad. After O(log n) steps Git prints the first bad commit. git bisect run <script> automates the test entirely.
5 / 5
What is the difference between git stash pop and git stash apply?
git stash push saves dirty working-tree changes (use -m "name" for a named stash). git stash pop restores the top entry and deletes it from the list — equivalent to apply + drop. git stash apply stash@{2} restores a specific entry without removing it, useful when you want the same stash on multiple branches. git stash list shows all saved entries.