Skip to main content

checkout_branch

Function checkout_branch 

Source
pub fn checkout_branch(cwd: &str, branch: &str) -> Result<String, String>
Expand description

Switch cwd to an existing local branch via git switch.

The branch is validated against the actual branch list to reject typos and argument injection (a name beginning with -). Returns the raw git stderr on failure so the caller can surface it (e.g. uncommitted-changes conflicts).