diff --git a/crates/services/src/services/git.rs b/crates/services/src/services/git.rs index d598f1e9..d34c5658 100644 --- a/crates/services/src/services/git.rs +++ b/crates/services/src/services/git.rs @@ -1418,15 +1418,24 @@ impl GitService { ) -> Result { let repo = self.open_repo(repo_path)?; let default_remote_name = self.default_remote_name(&repo); + let stripped_branch_name = match self.find_branch_type(repo_path, branch_name) { + Ok(BranchType::Remote) => { + // strip remote prefix if present + Ok(branch_name + .strip_prefix(&format!("{default_remote_name}/")) + .unwrap_or(branch_name)) + } + Ok(BranchType::Local) => Ok(branch_name), + Err(e) => Err(e), + }?; let remote = repo.find_remote(&default_remote_name)?; - let remote_url = remote .url() .ok_or_else(|| GitServiceError::InvalidRepository("Remote has no URL".to_string()))?; let git_cli = GitCli::new(); git_cli - .check_remote_branch_exists(repo_path, remote_url, branch_name) + .check_remote_branch_exists(repo_path, remote_url, stripped_branch_name) .map_err(|e| e.into()) }