On this page:
git_  branch_  create
git_  branch_  create_  from_  annotated
git_  branch_  delete
git_  branch_  is_  head
git_  branch_  iterator_  free
git_  branch_  iterator_  new
git_  branch_  lookup
git_  branch_  move
git_  branch_  name
git_  branch_  next
git_  branch_  set_  upstream
git_  branch_  upstream
8.12

4 Branch🔗ℹ

 (require libgit2/include/branch) package: libgit2

procedure

(git_branch_create repo    
  branch_name    
  target    
  force)  reference?
  repo : repository?
  branch_name : string?
  target : commit?
  force : boolean?
Create a new branch pointing at a target commit

A new direct reference will be created pointing to this target commit. If force is true and a reference already exists with the given name, it’ll be replaced.

The returned reference must be freed by the user.

The branch name will be checked for validity. See git_tag_create() for rules about valid names.

procedure

(git_branch_create_from_annotated repository    
  branch_name    
  commit    
  force)  reference?
  repository : repository?
  branch_name : string?
  commit : annotated_commit?
  force : boolean?
Create a new branch pointing at a target commit

This behaves like git_branch_create() but takes an annotated commit, which lets you specify which extended sha syntax string was specified by a user, allowing for more exact reflog messages.

See the documentation for git_branch_create().

procedure

(git_branch_delete branch)  integer?

  branch : reference?
Delete an existing branch reference.

If the branch is successfully deleted, the passed reference object will be invalidated. The reference must be freed manually by the user.

procedure

(git_branch_is_head branch)  boolean?

  branch : reference?
Determine if the current local branch is pointed at by HEAD.

procedure

(git_branch_iterator_free iter)  void?

  iter : branch_iterator?
Free a branch iterator

procedure

(git_branch_iterator_new repo list_flags)  branch_iterator?

  repo : repository?
  list_flags : git_branch_t
Create an iterator which loops over the requested branches.

procedure

(git_branch_lookup repo    
  branch_name    
  branch_type)  reference?
  repo : repository?
  branch_name : string?
  branch_type : git_branch_t
Lookup a branch by its name in a repository.

The generated reference must be freed by the user.

The branch name will be checked for validity. See git_tag_create() for rules about valid names.

procedure

(git_branch_move branch    
  new_branch_name    
  force)  reference?
  branch : reference?
  new_branch_name : string?
  force : boolean?
Move/rename an existing local branch reference.

The new branch name will be checked for validity. See git_tag_create() for rules about valid names.

procedure

(git_branch_name ref)  string?

  ref : reference?
Return the name of the given local or remote branch.

The name of the branch matches the definition of the name for git_branch_lookup. That is, if the returned name is given to git_branch_lookup() then the reference is returned that was given to this function.

procedure

(git_branch_next out_type iter)  any

  out_type : branch_t?
  iter : branch_iterator?
Retrieve the next branch and type from the iterator.

Returns (values repository? git_branch_t). See Multiple Values

procedure

(git_branch_set_upstream branch    
  upstream_name)  integer?
  branch : reference?
  upstream_name : string?
Set the upstream configuration for a given local branch

procedure

(git_branch_upstream branch)  reference?

  branch : reference?
Return the reference supporting the remote tracking branch, given a local branch reference.