Function: vc-switch-branch
vc-switch-branch is an autoloaded, interactive and byte-compiled
function defined in vc.el.gz.
Signature
(vc-switch-branch DIR NAME)
Documentation
Switch to the branch NAME in the directory DIR.
Interactively, prompt for DIR only for VCS that works at file level;
otherwise use the root directory of the current buffer's VC tree.
Interactively, prompt for the NAME of the branch.
After switching to the branch, check out and update the files to their
version on that branch.
Uses vc-retrieve-tag with the non-nil arg branchp.
Probably introduced at or before Emacs version 29.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/vc/vc.el.gz
;;;###autoload
(defun vc-switch-branch (dir name)
"Switch to the branch NAME in the directory DIR.
Interactively, prompt for DIR only for VCS that works at file level;
otherwise use the root directory of the current buffer's VC tree.
Interactively, prompt for the NAME of the branch.
After switching to the branch, check out and update the files to their
version on that branch.
Uses `vc-retrieve-tag' with the non-nil arg `branchp'."
(interactive
(let* ((granularity
(vc-call-backend (vc-responsible-backend default-directory)
'revision-granularity))
(dir
(if (eq granularity 'repository)
(expand-file-name (vc-root-dir))
(read-directory-name "Directory: " default-directory nil t))))
(list dir
(vc-read-revision "Switch to branch: "
(list dir)
(vc-responsible-backend dir)))))
(vc-retrieve-tag dir name t))