title | layout |
---|---|
(emacs-berlin 'archive') |
default |
{::options parse_block_html="true" /}
Using our collective wisdom we did some mob programming and created a useful litte function to undo the latest commit of a git repository. We also managed to get the *scratch* buffer into a state where it wouldn't display its contents anymore and had to start over. And learnt the basics of the prefix argument.
(defun magit/undo-last-commit (number-of-commits)
"Undoes the latest commit or commits without loosing changes"
(interactive "P")
(let ((num (if (numberp number-of-commits)
number-of-commits
1)))
(magit-reset (format "HEAD^%s" num))))