libgit2

git_branch_create

Version:

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.

Signature

int git_branch_create(git_oid *oid_out, git_repository *repo, const char *branch_name, const git_object *target, int force);

Parameters

In
oid_out

Pointer where to store the OID of the target commit.

In
repo

Repository where to store the branch.

const char *
In
branch_name

Name for the branch; this name is validated for consistency. It should also not conflict with an already existing branch name.

In
target

Object to which this branch should point. This object must belong to the given repo and can either be a git_commit or a git_tag. When a git_tag is being passed, it should be dereferencable to a git_commit which oid will be used as the target of the branch.

int
In
force

Overwrite existing branch.

Returns

int

0 or an error code. A proper reference is written in the refs/heads namespace pointing to the provided target commit.

Versions