SkillByAIOpen interactive version →

Lesson 20 / 28

git revert

Undo a shared commit safely with git revert, which adds a new opposite commit instead of rewriting history.

Undo without rewriting history

revert creates a new commit that undoes an earlier one — the original commit still exists in history.

git revert a1b2c3d

Output:

[main 4d5e6f7] Revert "Add experimental cache"

revert vs reset

Use revert on commits already pushed and shared — it's safe for everyone. Use reset only on local, unpushed commits.