Function: magit-stage
magit-stage is an interactive and byte-compiled function defined in
magit-apply.el.
Signature
(magit-stage &optional INTENT)
Documentation
Add the change at point to the staging area.
With a prefix argument, INTENT, and an untracked file (or files) at point, stage the file but not its content.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-apply.el
;;;; Stage
(defun magit-stage (&optional intent)
"Add the change at point to the staging area.
With a prefix argument, INTENT, and an untracked file (or files)
at point, stage the file but not its content."
(interactive "P")
(if-let ((s (and (derived-mode-p 'magit-mode)
(magit-apply--get-selection)))
(type (magit-diff-type))
(scope (magit-diff-scope)))
(pcase (list type scope
(magit-apply--ignore-whitespace-p s type scope))
(`(untracked ,_ ,_) (magit-stage-untracked intent))
(`(unstaged region ,_) (magit-apply-region s "--cached"))
(`(unstaged hunk ,_) (magit-apply-hunk s "--cached"))
(`(unstaged hunks ,_) (magit-apply-hunks s "--cached"))
('(unstaged file t) (magit-apply-diff s "--cached"))
('(unstaged files t) (magit-apply-diffs s "--cached"))
('(unstaged list t) (magit-apply-diffs s "--cached"))
('(unstaged file nil) (magit-stage-1 "-u" (list (oref s value))))
('(unstaged files nil) (magit-stage-1 "-u" (magit-region-values nil t)))
('(unstaged list nil) (magit-stage-modified))
(`(staged ,_ ,_) (user-error "Already staged"))
(`(committed ,_ ,_) (user-error "Cannot stage committed changes"))
(`(undefined ,_ ,_) (user-error "Cannot stage this change")))
(call-interactively #'magit-stage-files)))