Function: magit-worktree-checkout
magit-worktree-checkout is an autoloaded, interactive and
byte-compiled function defined in magit-worktree.el.
Signature
(magit-worktree-checkout DIRECTORY COMMIT)
Documentation
Checkout COMMIT in a new worktree in DIRECTORY.
COMMIT may, but does not have to be, a local branch.
Interactively, use magit-read-worktree-directory-function.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-worktree.el
;;;###autoload
(defun magit-worktree-checkout (directory commit)
"Checkout COMMIT in a new worktree in DIRECTORY.
COMMIT may, but does not have to be, a local branch.
Interactively, use `magit-read-worktree-directory-function'."
(interactive
(let ((commit (magit-read-branch-or-commit
"In new worktree; checkout" nil
(mapcar #'caddr (magit-list-worktrees)))))
(list (magit--read-worktree-directory commit (magit-local-branch-p commit))
commit)))
(when (zerop (magit-run-git "worktree" "add"
(magit--expand-worktree directory) commit))
(magit-diff-visit-directory directory)))