Which Git command undoes changes that have already been merged?

Dive into the Architect Journey – Development Lifecycle and Deployment Exam. Prep with tailored flashcards, explore multiple choice questions with detailed explanations, and enhance your readiness for the test!

Multiple Choice

Which Git command undoes changes that have already been merged?

Explanation:
Undoing changes that have already been merged requires a method that preserves history rather than rewriting it. Git revert fits this need because it creates a new commit that negates the effects of a previous commit. This keeps the project’s history intact while effectively “undoing” the change in the codebase. If you’re reverting a merge commit, you can specify which parent to keep with the -m option, telling Git how to apply the reversal. Why not other options? Reset changes the branch tip and can discard commits, which rewrites history and can disrupt shared branches—dangerous on a team project. Commit --amend only alters the most recent commit and doesn’t address changes already merged. Rebase rewrites history by replaying commits, also risky for published branches and requires coordination with others.

Undoing changes that have already been merged requires a method that preserves history rather than rewriting it. Git revert fits this need because it creates a new commit that negates the effects of a previous commit. This keeps the project’s history intact while effectively “undoing” the change in the codebase. If you’re reverting a merge commit, you can specify which parent to keep with the -m option, telling Git how to apply the reversal.

Why not other options? Reset changes the branch tip and can discard commits, which rewrites history and can disrupt shared branches—dangerous on a team project. Commit --amend only alters the most recent commit and doesn’t address changes already merged. Rebase rewrites history by replaying commits, also risky for published branches and requires coordination with others.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy