Function: forge-fork

forge-fork is an autoloaded, interactive and byte-compiled function defined in forge-commands.el.

Signature

(forge-fork FORK REMOTE ALL)

Documentation

Fork the current repository to FORK and add it as a REMOTE.

If the fork already exists, then that isn't an error; the remote is added anyway. Currently this only supports Github and Gitlab.

With prefix argument ALL, fork all branches, not just the default branch. On Gitlab it is not possible to fork only the default.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/forge-20260408.1922/forge-commands.el
;;; Remotely

;;;###autoload
(defun forge-fork (fork remote all)
  "Fork the current repository to FORK and add it as a REMOTE.

If the fork already exists, then that isn't an error; the remote
is added anyway.  Currently this only supports Github and Gitlab.

With prefix argument ALL, fork all branches, not just the default
branch.  On Gitlab it is not possible to fork only the default."
  (interactive
    (let ((fork (magit-completing-read "Fork to"
                                       (mapcar #'car forge-owned-accounts))))
      (list fork
            (read-string "Remote name: "
                         (or (plist-get (cdr (assoc fork forge-owned-accounts))
                                        'remote-name)
                             fork))
            current-prefix-arg)))
  (let ((repo (forge-get-repository :stub)))
    (forge--fork-repository repo fork all)
    (magit-remote-add remote
                      (magit-clone--format-url (oref repo githost) fork
                                               (oref repo name))
                      (list "--fetch"))))