CS FundamentalsHardWipro · Accenture pattern
A bad commit has already been pushed to a shared main branch that teammates have pulled. What is the safest way to undo it?
- A. git reset --hard <commit>~1 followed by git push --force
- B. git commit --amend
- C. Delete the branch and push it again
- D. git revert <commit>, which adds a new commit that undoes the change
Correct answer: D. git revert <commit>, which adds a new commit that undoes the change
git revert keeps history intact and is safe for shared branches. Resetting and force-pushing rewrites history that others already have, breaking their clones; --amend only edits the latest commit and also rewrites history.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- When does git merge feature (run on main) produce a fast-forward instead of a merge commit?
- A stock-price service must notify every registered display widget whenever the price changes, without knowing the widgets' concrete…
- Your application expects a PaymentGateway interface, but the third-party library you must use exposes a different API. Which pattern lets…
- class Square extends Rectangle overrides setWidth() so that it also changes the height. Code that sets width = 5 and height = 4 on a…
- A ReportService creates a new MySqlDatabase() directly inside its constructor. Refactoring it to receive a Database interface through its…
- Which HTTP method is NOT idempotent by definition?