Function: magit-worktree-move
magit-worktree-move is an autoloaded, interactive and byte-compiled
function defined in magit-worktree.el.
Signature
(magit-worktree-move WORKTREE DIRECTORY)
Documentation
Move existing WORKTREE directory to DIRECTORY.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-worktree.el
;;;###autoload
(defun magit-worktree-move (worktree directory)
"Move existing WORKTREE directory to DIRECTORY."
(interactive
(list (magit-completing-read "Move worktree"
(cdr (magit-list-worktrees))
nil t nil nil
(magit-section-value-if 'worktree))
(read-directory-name "Move worktree to: ")))
(if (file-directory-p (expand-file-name ".git" worktree))
(user-error "You may not move the main working tree")
(let ((preexisting-directory (file-directory-p directory)))
(when (and (zerop (magit-call-git "worktree" "move" worktree
(magit--expand-worktree directory)))
(not (file-exists-p default-directory))
(derived-mode-p 'magit-status-mode))
(kill-buffer)
(magit-diff-visit-directory
(if preexisting-directory
(concat (file-name-as-directory directory)
(file-name-nondirectory worktree))
directory)))
(magit-refresh))))