使用 libgit2 将所有提交合并到单个提交中的方法
way to combine all commits into a single commit using libgit2
我想将所有提交合并为一个以删除历史记录。我知道在 Git 命令行中这是可能的,但我还没有在 libgit2 中找到方法。
我在最新版本中使用libgit2,由我在C++年编译。
你有什么建议?
有几种方法可以考虑这个问题。在命令行上,您可以执行以下操作:
git reset --soft <some-ancestor-commit-ish>
git commit -m "This commit combines some history."
软重置将当前分支移动到指向某个祖先提交,而不更改工作目录和索引。因此,现在您已经暂存了这些提交引入的所有更改,并且可以将它们作为新的组合提交提交。这两个步骤可以直接转换为 libgit2
,如下所示:git_reset(repo, ancestor_commit, GIT_RESET_SOFT, NULL);
git_commit_create(...);
相关文章:
- 在Google Kick start中提交时出错
- 如何将一个ostringstream十六进制字符串字符对转换为单个unit8t等价的二进制值
- 多个If语句与使用逻辑运算符计算条件的单个语句的比较
- 使用libcurl提交批量url的正确BING Api POST url是什么
- 在 leetcode 上提交解决方案时出现堆栈缓冲区溢出错误
- Eclipse CDT:单个项目中有多个C++文件
- 为什么我们将单个或多维数组的大小声明为常量值?
- C++调用具有 *this 属性的单个帮助程序函数
- 如何读取单个字符并在输入两个字符序列时输出? 使用 while 循环和C++
- 如何将可变参数模板转换为多个单个模板?(C++竞争编程调试模板)
- 将多个 for 循环组合成单个迭代器
- 如何将多种语言设置放在单个 .clang 格式文件中
- QT QOpenGLWidget:如何在不使用数据块复制的情况下修改VBO中的单个顶点值?
- 在 c++ 中对单个排序数组中的 2 个未排序数组进行排序
- 与多个 for 循环与单个 for 循环 wrt 相关的性能从多映射获取数据
- C++:如何用单个命令替换复杂的迭代?
- C++单个生成文件多个二进制文件
- 将单个未唱的 int 发送到 VBO
- 如何限制在C++中为单个类创建的对象数量?
- 使用 libgit2 将所有提交合并到单个提交中的方法