Undo last commit and unstage changes

Move HEAD back one commit. Changes stay in your files but are no longer staged

git reset HEAD~1

tool
git45 commands
tags
git

More git commands

  • git restore . && git clean -fd

    Discard unstaged edits in tracked files and delete untracked files and directories

  • git tag -l -n1

    List all tags with the first line of each annotation

  • git tag -s v1.2.3 -m 'Release 1.2.3'

    Create an annotated tag signed with GPG for a release

  • git fetch --prune

    Remove local refs to remote branches that no longer exist

  • git clone --depth=1 --single-branch --branch main <url>

    Clone only the latest commit of one branch. Good for fast CI checkouts

all 45 git commands