gpt4 book ai didi

c - 在 git index 中添加了修改后的文件,但该文件未更改为暂存文件

转载 作者:太空狗 更新时间:2023-10-29 13:20:12 24 4
gpt4 key购买 nike

我正在尝试将文件添加到索引以使用 libgit2 创建提交。

repo 和 index 是这样的:

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.

“a.txt”文件已存在于索引中,是修改后的文件。

在提交之前,该文件位于“Changes not staged for commit”下,我认为之后该文件将处于“暂存”状态,就像我执行“git add a.txt”之后一样,但那并没有发生。

我错过了什么吗?

最佳答案

对索引的更改不会立即写入磁盘。例如,您可能希望执行多项操作并一次保存所有操作。为了保存索引:

git_index_write(my_repo_index);

关于c - 在 git index 中添加了修改后的文件,但该文件未更改为暂存文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20722783/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com