Skip to main content

create_branch

Function create_branch 

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

Create a new branch off the current HEAD and switch to it (git switch -c).

Guards against argument injection (a name beginning with -) and obvious bad input; git validates the full ref-name grammar itself and errors cleanly. Returns the raw git stderr on failure (e.g. the branch already exists).