git reset <commit> --merge

Undo commits without touching the working tree.

This command moves the current branch to the specified <commit> and updates the index, but leaves the working tree as it is.

This is useful if you want to discard commits but keep your workspace changes.

The --merge flag specifically preserves uncommitted changes by keeping files that are different between the <commit> and the working tree.

Variants include using --hard to reset both the working tree and index, or --soft to leave both the working tree and the index intact.