What the .emacs.d!?

I mess up a lot, and often want to do a quick amend to the last commit.


;; C-c C-a to amend without any prompt

(defun magit-just-amend ()
  (interactive)
  (save-window-excursion
    (magit-with-refresh
      (shell-command "git --no-pager commit --amend --reuse-message=HEAD"))))

(eval-after-load "magit"
  '(define-key magit-status-mode-map (kbd "C-c C-a") 'magit-just-amend))

This code will let me just press C-c C-a and it amends with no fuss at all.

Thanks to this post for the inspiration.


Update! As noted by Kyle Meyer in the comments below, this no longer works in the newest magit. Instead you should be using the built in Extend Commit command: c e.

blog comments powered by Disqus