libgit2

git_repository_set_head

Version:

Make the repository HEAD point to the specified reference.

If the provided reference points to a Tree or a Blob, the HEAD is unaltered and -1 is returned.

If the provided reference points to a branch, the HEAD will point to that branch, staying attached, or become attached if it isn't yet. If the branch doesn't exist yet, no error will be return. The HEAD will then be attached to an unborn branch.

Otherwise, the HEAD will be detached and will directly point to the Commit.

Signature

int git_repository_set_head(git_repository *repo, const char *refname);

Parameters

In
repo

Repository pointer

const char *
In
refname

Canonical name of the reference the HEAD should point at

Returns

int

0 on success, or an error code

Versions