Function: vc-create-branch

vc-create-branch is an autoloaded, interactive and byte-compiled function defined in vc.el.gz.

Signature

(vc-create-branch DIR NAME)

Documentation

Make a branch called NAME in directory DIR.

After making the new branch, check out the branch, i.e. update the files in the tree to their revisions on the branch.

Interactively, prompt for the NAME of the branch.

With VCSes that maintain version information per file, this command also prompts for the directory DIR whose files, recursively, will be tagged with the NAME of new branch. For VCSes that maintain version information for the entire repository (all the modern decentralized VCSes belong to this group), DIR is always the default-directory.

Finally, this command might prompt for the branch or tag from which to start ("fork") the new branch, with completion candidates including all the known branches and tags in the repository.

This command invokes vc-create-tag with the non-nil BRANCHP argument.

View in manual

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-create-branch (dir name)
  "Make a branch called NAME in directory DIR.
After making the new branch, check out the branch, i.e. update the
files in the tree to their revisions on the branch.

Interactively, prompt for the NAME of the branch.

With VCSes that maintain version information per file, this command also
prompts for the directory DIR whose files, recursively, will be tagged
with the NAME of new branch.  For VCSes that maintain version
information for the entire repository (all the modern decentralized
VCSes belong to this group), DIR is always the `default-directory'.

Finally, this command might prompt for the branch or tag from which to
start (\"fork\") the new branch, with completion candidates including
all the known branches and tags in the repository.

This command invokes `vc-create-tag' with the non-nil BRANCHP argument."
  (interactive
   (let ((granularity
          (vc-call-backend (vc-responsible-backend default-directory)
                           'revision-granularity)))
     (list
      (if (eq granularity 'repository)
          default-directory
        (read-directory-name "Directory: " default-directory default-directory t))
      (read-string "New branch name: " nil 'vc-revision-history))))
  (vc-create-tag dir name t))