LinuxCommandLibrary

git-undo

Undo recent commits while preserving changes

TLDR

Undo last commit

$ git undo
copy
Undo N commits
$ git undo [3]
copy
Undo and keep changes staged
$ git undo --soft
copy
Undo and discard changes
$ git undo --hard
copy

SYNOPSIS

git undo [count] [options]

DESCRIPTION

git undo removes the last commit(s) while keeping changes in the working directory. It is a safer alternative to `git reset` that defaults to preserving work.
The command makes it easy to fix mistakes, amend commits, or restructure recent history. Different modes control whether changes remain staged or unstaged.

PARAMETERS

COUNT

Number of commits to undo (default: 1).
--soft
Keep changes staged.
--hard
Discard all changes.
--help
Display help information.

CAVEATS

Part of git-extras package. Only affects local commits. --hard discards changes permanently.

HISTORY

git undo is part of git-extras, providing a friendlier interface to the common reset operation.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community