Default branch/remote
Several parts of git-prole rely on a concept of a “default branch” or
“default remote”:
-
When using
git prole convertto convert an existing repository into a worktree checkout, a worktree is created for the default branch. -
When using
git prole addto create a new worktree, the created branch will start at the default branch.
Here’s how a default branch is determined:
-
We attempt to find a default remote:
-
If a remote matching Git’s
checkout.defaultRemotesetting is found, we use that. -
Otherwise, we attempt to find a default remote by matching against the
remote_namesconfiguration setting, which defaults toupstreamandorigin.
-
-
If we find a default remote, we use
git ls-remote --symref "$REMOTE" HEADto determine the default branch for that remote. -
If no default remote is found, we attempt to find a default local branch by matching against the
branch_namesconfiguration setting, which defaults tomain,master, andtrunk.