Function: forge-rename-default-branch

forge-rename-default-branch is an interactive and natively compiled function defined in forge-commands.el.

Signature

(forge-rename-default-branch)

Documentation

Rename the default branch on the upstream remote and locally.

Also update the upstream branches of local branches accordingly.

Key Bindings

This command is not in any keymaps.

Source Code

;; Defined in /nix/store/923zwib42c4qw6x4xps0cv1wi8qcd6lp-emacs-packages-deps/share/emacs/site-lisp/elpa/forge-20261005.753/forge-commands.el
;;;###autoload
(defun forge-rename-default-branch ()
  "Rename the default branch on the upstream remote and locally.
Also update the upstream branches of local branches accordingly."
  (interactive)
  (pcase-let* ((`(,repo ,old) (forge--set-default-branch-read-args))
               (default (and (not (equal old "main")) "main"))
               (new (read-string
                     (format "Rename default branch `%s' to%s: " old
                             (if default (format " (default: %s)" default) ""))
                     nil nil default)))
    (message "Renaming default branch...")
    (forge--rename-branch repo new old)
    (magit--set-default-branch new old)
    (magit-git "remote" "set-head" "--auto" (oref repo remote))
    (forge-refresh-buffer)
    (message "Renaming default branch...done")))