Functions
2.1 Annotated Commit
2.2 Blame
2.3 Blob
2.4 Branch
2.5 Buffer
2.6 Checkout
2.7 Cherrypick
2.8 Clone
2.9 Commit
2.10 Config
2.11 Credentials
2.12 Describe
2.13 Diff
2.14 Fetch
2.15 Filter
2.16 Errors
2.17 Graph
2.18 Ignore
2.19 Index
2.20 Indexer
2.21 Global
2.22 Merge
2.23 Message
2.24 Note
2.25 Object
2.26 Object Database
2.27 Oid
2.28 Oid Array
2.29 Packbuilder
2.30 Patch
2.31 Pathspec
2.32 Proxy
2.33 Push
2.34 Rebase
2.35 Refdb
2.36 Reference
2.37 Reflog
2.38 Refspec
2.39 Remote
2.40 Repository
2.41 Reset
2.42 Revert
2.43 Revparse
2.44 Revwalk
2.45 Signature
2.46 Stash
2.47 Status
2.48 Strarray
2.49 Submodule
2.50 Tag
2.51 Tree
2.52 Treebuilder
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
7.7

2.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.