我一直在研究libgit2 C API reference,但我不知道如何才能模仿git commit --allow-empty的行为。libgit2有没有内置的方法来创建空提交?如果不是,git如何在幕后创建一个空的提交,我应该如何使用libgit2来实现相同的行为?
发布于 2018-09-06 06:09:57
使用与父提交相同的树调用git_commit_create。这就是:
// Get parent somehow.
git_commit *parent = ...;
// Use the same tree as the parent.
git_tree *tree;
git_commit_tree(&tree, parent);
// Create the commit.
git_commit_create(..., tree, 1, parent);https://stackoverflow.com/questions/52188664
复制相似问题