Pergunta

I'm trying to add a file to index to create a commit with libgit2.

The repo and index are like that:

git_repository *repo;
git_index *my_repo_index;
git_repository_open(&repo, ".");
git_repository_index(&my_repo_index, repo);
git_index_add_bypath(my_repo_index,"a.txt");
//all functions are returning 0, or success.

The "a.txt" file already exists in the index and is a modified file.

Before the commit the file is under "Changes not staged for commit", and I thought that after that the file would be under "staged" like after I executed "git add a.txt" but that didn't happened.

Am I missing something?

Foi útil?

Solução

Changes to the index are not immediately written to disk. You might, for example, wish to perform a number of actions and save them all at once. In order to save the index:

git_index_write(my_repo_index);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top