Undo (restore, revert, reset)

Git offers several ways to undo. git restore discards local changes or removes files from the staging area. git revert creates a new commit that undoes an existing commit, without rewriting history. git reset moves the branch and can destroy commits: use with caution.

Example

git restore fichier.py
git revert a1b2c3d

Related concepts

The whole glossary