Branches
Branch operations are available via repo.branches.
List branches
Section titled “List branches”// Local brancheslet locals = try repo.branches.list()
// Remote brancheslet remotes = try repo.branches.list(type: .remote)
// Alllet all = try repo.branches.list(type: .all)Each item is a Branch with .name, .shortName, and .isHead.
Create a branch
Section titled “Create a branch”let commit = try repo.log(limit: 1).first!let branch = try repo.branches.create(named: "feature/my-feature", at: commit)Checkout
Section titled “Checkout”try repo.branches.checkout(named: "feature/my-feature")Delete
Section titled “Delete”try repo.branches.delete(named: "feature/my-feature")Rename
Section titled “Rename”try repo.branches.rename("old-name", to: "new-name")Current branch
Section titled “Current branch”let branches = try repo.branches.list()let current = branches.first(where: { $0.isHead })print(current?.shortName ?? "detached HEAD")