Function: magit-primary-remote
magit-primary-remote is a byte-compiled function defined in
magit-git.el.
Signature
(magit-primary-remote)
Documentation
Return the primary remote.
The primary remote is the remote that tracks the repository that other repositories are forked from. It often is called "origin" but because many people name their own fork "origin", using that term would be ambiguous. Likewise we avoid the term "upstream" because a branch's @{upstream} branch may be a local branch or a branch from a remote other than the primary remote.
If a remote exists whose name matches magit.primaryRemote, then
that is considered the primary remote. If no remote by that name
exists, then remotes in magit-primary-remote-names are tried in
order and the first remote from that list that actually exists in
the current repository is considered its primary remote.
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-git.el
(defun magit-primary-remote ()
"Return the primary remote.
The primary remote is the remote that tracks the repository that
other repositories are forked from. It often is called \"origin\"
but because many people name their own fork \"origin\", using that
term would be ambiguous. Likewise we avoid the term \"upstream\"
because a branch's @{upstream} branch may be a local branch or a
branch from a remote other than the primary remote.
If a remote exists whose name matches `magit.primaryRemote', then
that is considered the primary remote. If no remote by that name
exists, then remotes in `magit-primary-remote-names' are tried in
order and the first remote from that list that actually exists in
the current repository is considered its primary remote."
(let ((remotes (magit-list-remotes)))
(seq-find (##member % remotes)
(delete-dups
(delq nil
(cons (magit-get "magit.primaryRemote")
magit-primary-remote-names))))))