create_branch: check out if it exists
@@ -73,6 +73,12 @@ class PackitRepositoryBase:
"""
# it's not an error if the branch already exists
origin = self.local_project.git_repo.remote("origin")
+ if branch_name in self.local_project.git_repo.branches:
+ logger.debug(
+ f"It seems that branch {branch_name} already exists, checking it out."
+ )
+ head = self.local_project.git_repo.branches[branch_name]
+ else:
head = self.local_project.git_repo.create_head(branch_name, commit=base)
if setup_tracking:
