简体   繁体   English

Git mega squash用相同的消息和作者压缩所有顺序提交

[英]Git mega squash all sequential commits with same message and author

I have an application which monitors a file-system (TeamCity config directory), for changes to XML configuration files. 我有一个监视文件系统(TeamCity配置目录)的应用程序 ,以更改XML配置文件。 When a change is detected, it is committed to Git (with libgit2sharp ). 检测到更改后,会将其提交给Git(使用libgit2sharp )。 The Git 'Committer' is always the service account user that the application runs under, but the Git 'Author' is determined by examining the TeamCity audit log so that the change is attributed to the user who made it. Git的“提交者”始终是应用程序运行所在的服务帐户用户,但是Git的“作者”是通过检查TeamCity审核日志来确定的,以便将更改归因于创建它的用户。 The application records a generic commit message like "build configuration 'x' was modified by user 'y'." 该应用程序记录一条通用的提交消息,例如“用户'y'修改了构建配置'x'”。 and commits the change. 并提交更改。

Since TeamCity configuration changes tend to be made as a series of web page interactions, we end up with lots (10 to 30 or so) of sequential commits, showing the change to a given configuration file (generally, the same one (build-config) or two (vcs-config) files are changed in the whole series of commits). 由于TeamCity配置更改通常是通过一系列的网页交互来进行的,因此最终会有大量(10到30个左右)的顺序提交,显示对给定配置文件的更改(通常是相同的配置(build-config) )或在整个提交系列中更改了两个(vcs-config)文件)。

I want to squash all sequential commits with the same commit message and author into a single commit. 我想用相同的提交消息压缩所有顺序的提交,然后将作者编写为单个提交。 Is there a git command that can do this for a whole repo in one shot or do I need to script a sequence of calls for each sequence of commits that I want to squash? 是否有一个git命令可以一次完成整个仓库,或者我需要为要压缩的每个提交序列编写一个调用序列的脚本?

When working with libgit2sharp, I have found that it makes sense to work out what I want to achieve in vanilla git and afterwards implement the git command in the c# code. 当使用libgit2sharp时,我发现有意义的是在香草git中计算出我想要实现的目标,然后在c#代码中实现git命令。 but perhaps someone already knows the correct sequence of libgit2sharp calls to make this work. 但是也许有人已经知道正确的libgit2sharp调用顺序才能使此工作生效。

I don't think it's ever been used to compress history before, but you could experiment with LibGit2Sharp's RewriteHistory api. 我认为以前从未使用过它来压缩历史记录,但是您可以尝试使用LibGit2Sharp的RewriteHistory API。 Check out the tests for how it's usually invoked. 检查一下通常如何调用它的测试 Some combination of TreeFilter and ParentFilter might do what you want. TreeFilterParentFilter某种组合可能会满足您的要求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无论分支如何,如何使用 libgit2sharp 获取所有 git 提交? - How to get all git commits with libgit2sharp, regardless the branch? 在GIT中删除一些提交 - Remove some commits in GIT 验证重写历史记录后,验证C#项目的所有Git提交是否都已编译 - Verify that all Git commits of a C# project compile after rewriting history 什么是最简单的方法将git上的所有提交返回到尚未合并的master分支? - Whats the simplest way to return all commits on git to master branch that have not been merged already? 错误消息对所有字段显示相同的错误 - Error message display the same error for all fields 如何使用 VSTS Git API for C# 获取给定提交 ID 的所有拉取请求 ID(来自合并提交) - How can I get all pull requests Ids (from merged commits) for a given commit Id using VSTS Git API for C# 不同的事务同时提交 - Different transaction commits at same time MSMQ:MSMQ是否保证顺序消息传递? - MSMQ: Does MSMQ guarantees sequential message passing? MassTransit - 多个消费者都可以收到相同的消息吗? - MassTransit - Can Multiple Consumers All Receive Same Message? 向同一网络上的应用程序的所有实例发送消息的方式是什么? - What means are there for sending a message to all instances of an application on the same network?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM