Function: magit-reverse

magit-reverse is an interactive and natively compiled function defined in magit-apply.el.

Signature

(magit-reverse &rest ARGS)

Documentation

Reverse the change at point in the working tree.

With a prefix argument fallback to a 3-way merge. Doing so causes the change to be applied to the index as well.

Key Bindings

This command is not in any keymaps.

Source Code

;; Defined in /nix/store/irvbdy0zra0dn8fpd008f32x5ix6qm5v-emacs-packages-deps/share/emacs/site-lisp/elpa/magit-20261005.508/magit-apply.el
;;;; Reverse

(defun magit-reverse (&rest args)
  "Reverse the change at point in the working tree.
With a prefix argument fallback to a 3-way merge.  Doing
so causes the change to be applied to the index as well."
  (interactive (and current-prefix-arg (list "--3way")))
  (when$ (magit-apply--get-selection)
    (pcase (list (magit-diff-type) (magit-diff-scope))
      (`(untracked ,_) (user-error "Cannot reverse untracked changes"))
      (`(unstaged  ,_) (user-error "Cannot reverse unstaged changes"))
      (`(,_    region) (magit-reverse-region $ args))
      (`(,_      hunk) (magit-reverse-hunk   $ args))
      (`(,_     hunks) (magit-reverse-hunks  $ args))
      (`(,_      file) (magit-reverse-file   $ args))
      (`(,_     files) (magit-reverse-files  $ args))
      (`(,_      list) (magit-reverse-files  $ args)))))