August 22, 2023

Git: Undo the last commit, nothing more

$ git reset --soft HEAD^

will undo the last commit.

The file(s) you had commited will be back in the staging cache.

Source: git’s man pages:

Undo a commit and redo

$ git commit …
$ git reset –soft HEAD^ (1)

  1. This is most often done when you remembered what you just committed is incomplete, or you misspelled your commit message, or both. Leaves working tree as it was before reset”.

personal computing command-line interface (cli) gnu linux trisquel shell literacy office applications wiki git

No affiliate links, no analytics, no tracking, no cookies. This work © 2016-2024 by yctct is licensed under CC BY-ND 4.0 .   about me   contact me   all entries & tags   FAQ   GPG public key

GPG fingerprint: 2E0F FB60 7FEF 11D0 FB45 4DDC E979 E52A 7036 7A88