Function: magit-checkout-remote-ref

magit-checkout-remote-ref is an autoloaded, interactive and byte-compiled function defined in magit-branch.el.

Signature

(magit-checkout-remote-ref REMOTE REF)

Documentation

Checkout reference REF from REMOTE.

This command queries the REMOTE for a list of its references. After the user has selected on of them, it fetches just that, and finally it checks out "FETCH_HEAD", which now refers to the same commit as REF does on REMOTE.

This is only useful if you usually only fetch a subset of the refs from REMOTE. Otherwise it is better to use magit-checkout, as that avoids a round-trip.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260822.1158/magit-branch.el
;;;###autoload
(defun magit-checkout-remote-ref (remote ref)
  "Checkout reference REF from REMOTE.

This command queries the REMOTE for a list of its references.  After
the user has selected on of them, it fetches just that, and finally
it checks out \"FETCH_HEAD\", which now refers to the same commit as
REF does on REMOTE.

This is only useful if you usually only fetch a subset of the refs
from REMOTE.  Otherwise it is better to use `magit-checkout', as
that avoids a round-trip."
  (declare (interactive-only magit-call-git))
  (interactive
    (let ((remote (magit-read-remote "Checkout ref from remote" nil t)))
      (list remote
            (magit-completing-read
             "Fetch and checkout ref"
             (prog2 (message "Fetching list of remote refs...")
                 (magit-remote-list-refs remote)
               (message "Fetching list of remote refs...done"))))))
  (magit-run-git-async "fetch" remote ref)
  (set-process-sentinel
   magit-this-process
   (lambda (process _event)
     (when (memq (process-status process) '(exit signal))
       (magit--checkout "FETCH_HEAD")
       (magit-refresh)))))