Reversing Changes in Git
Task
Undo the latest changes in two branches, taking into account whether the history has been published or not.
Steps
- In the
localbranch, remove the last local commit by rewriting history. - Switch to the
pushedbranch. - Undo its last published commit with a new reverting commit, without moving the branch backward.
Expected result
local must return to C1. The pushed branch must get a new revert commit on top of C2, and HEAD must stay on pushed.
What you will learn
After completing the task, you will be able to:
- choose between reset and revert;
- safely undo published changes;
- understand the difference between rewriting history and adding a new reverting commit.
Goal
local