Function: magit-checkout
magit-checkout is an interactive and natively compiled function
defined in magit-branch.el.
Signature
(magit-checkout COMMIT &optional ARGS)
Documentation
Checkout COMMIT, updating the index and the working tree.
If COMMIT is a local branch, then that becomes the current
branch. If it is something else, then HEAD becomes detached.
Checkout fails if the working tree or the staging area contain
changes.
(git checkout COMMIT).
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-branch.el
;;;###autoload
(defun magit-checkout (commit &optional args)
"Checkout COMMIT, updating the index and the working tree.
If COMMIT is a local branch, then that becomes the current
branch. If it is something else, then `HEAD' becomes detached.
Checkout fails if the working tree or the staging area contain
changes.
\n(git checkout COMMIT)."
(declare (interactive-only magit--checkout))
(interactive (list (magit-read-other-branch-or-commit "Checkout")
(magit-branch-arguments)))
(when (string-match "\\`heads/\\(.+\\)" commit)
(setq commit (match-str 1 commit)))
(magit-run-git-async "checkout" args commit))