Skip to content

Instantly share code, notes, and snippets.

@aeinbu
Last active February 12, 2025 14:47
Show Gist options
  • Save aeinbu/dbdd2fbdee37cbb87ce0ebf36404f089 to your computer and use it in GitHub Desktop.
Save aeinbu/dbdd2fbdee37cbb87ce0ebf36404f089 to your computer and use it in GitHub Desktop.
Git reset

git reset

  • git reset --soft, any changes are left as staged (or "ready to commit")
  • git reset --mixed, any changes are left as unstaged
  • git reset --hard, any changes are discarded

Example:

git reset --soft HEAD^

Navigating git

Shortcuts for path-specs

  • HEAD is the current commit
  • HEAD^ is the same as HEAD~1, meaning one commit back from current commit
  • HEAD^^ is the same as HEAD~2, meaning two commits back from current commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment