libgit2

git_index_add

Version:

Add or update an index entry from a file in disk

The file path must be relative to the repository's working folder and must be readable.

This method will fail in bare index instances.

This forces the file to be added to the index, not looking at gitignore rules. Those rules can be evaluated through the git_status APIs (in status.h) before calling this.

Signature

int git_index_add(git_index *index, const char *path, int stage);

Parameters

In
index

an existing index object

const char *
In
path

filename to add

int
In
stage

stage for the entry

Returns

int

GIT_SUCCESS or an error code

Versions