index rss mastodon twitter github linkedin email
Álvaro Ramírez

Álvaro Ramírez

11 February 2016 Doh! undo last commit (Magit edition)

I previously noted how to undo your last git commit (ie. soft reset). Using Magit:

  1. M-x magit-log-current.
  2. Move point to prior revision.
  3. M-x magit-reset-soft (defaults to revision at point).

Or if you want a single function:

(require 'magit)

(defun ar/magit-soft-reset-head~1 ()
  "Soft reset current git repo to HEAD~1."
  (magit-reset-soft "HEAD~1"))