Skip to main content

get_default_branch

Function get_default_branch 

Source
pub fn get_default_branch(repo: &Repository) -> Result<String>
Expand description

Get the default branch name for a repository, validated to exist.

This function:

  1. Checks the init.defaultBranch config
  2. Falls back to “main” if it exists
  3. Falls back to “master” if it exists
  4. Returns an error if none exist