350-901 · Question #57
Drag and drop the steps from the left into the correct sequence on the right to describe how to use Git to maintain the current HEAD and revert back to a previous commit, while undoing all…
This question tests knowledge of using 'git revert' to undo a series of intermediate commits while preserving history and keeping HEAD in place. Unlike 'git reset', revert creates new commits that invert prior changes without rewriting history.
Question
Explanation
This question tests knowledge of using 'git revert' to undo a series of intermediate commits while preserving history and keeping HEAD in place. Unlike 'git reset', revert creates new commits that invert prior changes without rewriting history.
Approach. The correct sequence is: (1) Run 'git log --oneline' to identify the target commit hash and the range of commits to undo. (2) Execute 'git revert <oldest-bad-commit>^..<HEAD>' (or 'git revert --no-commit <range>' to batch them into one commit). (3) Resolve any merge conflicts if they arise. (4) Finalize with 'git commit' (if using --no-commit) and optionally 'git push' to publish. This approach is correct because 'git revert' adds new inverse commits on top of HEAD rather than moving HEAD backward, making it safe for shared/remote branches where rewriting history would cause problems.
Concept tested. git revert vs git reset: understanding that 'git revert' preserves the existing commit history and HEAD position by appending new undo-commits, whereas 'git reset --hard' destructively moves HEAD back and erases intermediate commits from history. The question specifically targets the non-destructive, history-safe reversal workflow.
Reference. Git documentation: 'git revert' - https://git-scm.com/docs/git-revert
Topics
Community Discussion
No community discussion yet for this question.