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?
The “changes not staged for commit” message shows when you run the “git status” command and have a file that has been changed but has not yet been added to the staging area. This is not an error message, rather a notification that you have changed files that are not in the staging area or a commit.
If your changes are already staged, then there's no difference to show. But there's a command line option that will show you staged changes if you specify it: git diff --staged . With the --staged option, git diff will compare your staged changes against the previous commit.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With