git将多个提交压缩为多个提交 [英] git squashing multiple commits into multiple commits

查看:119
本文介绍了git将多个提交压缩为多个提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于此:

在推入Git之前组合多个提交

假设我有这个基准:

pick 16b5fcc msg1
pick c964dea msg3
pick 06cf8ee msg1
pick 396b4a3 msg2
pick 9be7fdb msg3
pick 7dba9cb msg2

假设我要将具有相同消息的所有Comit合并为一个...(即,所有msg1都提交为一个msg1 commit,所有msg2 commit变成1 msg2 commit,等等)

Suppose I want to combine all comitts with the same message into one...(ie all msg1 commits into a single msg1 commit, all msg2 commits into 1 msg2 commit, etc)

我应该如何挤压这些?

How should I go about squashing these?

推荐答案

git-rebase可让您重新排序和压缩提交。这样的东西应该起作用:

git-rebase lets you reorder and squash commits. Something like this ought to work:

pick 16b5fcc msg1
squash 06cf8ee msg1
pick 396b4a3 msg2
squash 7dba9cb msg2
pick 9be7fdb msg3
squash c964dea msg3

如果提交很多,我建议您编写一个脚本将其分组,如上。

If you have a lot of commits, I would suggest you write a script to group them as above.

这篇关于git将多个提交压缩为多个提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆