Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要提交所有工作目录,但我找不到任何可以将子目录添加到索引的解决方案。我试过了,git_index_add_bypath()但似乎没有为子目录添加树。我正在使用 Qt 和 c 的 libgit2,因为 Qt 的语言绑定似乎不起作用。
git_index_add_bypath()
根据您的需要,有不同的方法。“提交所有工作目录”没有传达哪一个。
如果要更新跟踪的每个文件的版本,可以遍历索引中的条目并调用git_index_add_bypath每个条目。
git_index_add_bypath
对于其他任何事情,事情都会变得模糊不清,因为您可能想也可能不想考虑忽略规则。一般的解决方案是使用状态 API 查看哪些文件已更改或添加,并根据您要查找的结果将这些文件添加到索引中(忽略规则、添加新文件或不添加新文件、删除未添加的文件在工作树中)。