Git 挤压推送提交的组

Git 挤压推送提交的组,git,squash,Git,Squash,很好地解释了如何在推送后挤压最后几个提交,但是如何将最后12个提交分成三组,每组四个?也就是说,我已经推了提交1-12次,现在想将它们压缩为三次提交。这三个压缩提交将分别包含原始提交1-6、7-8和9-12。我该怎么做 优点:如何为三个压缩提交中的每一个指定新的提交消息?使用 git-rebase-i[提交之前要挤压的对象 标记要挤压的s(用于挤压)和要保留的e进行编辑的 然后它将以交互方式挤压中间的消息,并在其他消息处停止。然后使用git commit-a--amend编辑提交消息,使用git

很好地解释了如何在推送后挤压最后几个提交,但是如何将最后12个提交分成三组,每组四个?也就是说,我已经推了提交1-12次,现在想将它们压缩为三次提交。这三个压缩提交将分别包含原始提交1-6、7-8和9-12。我该怎么做

优点:如何为三个压缩提交中的每一个指定新的提交消息?

使用
git-rebase-i[提交之前要挤压的对象

标记要挤压的
s
(用于挤压)和要保留的
e
进行编辑的

然后它将以交互方式挤压中间的消息,并在其他消息处停止。然后使用
git commit-a--amend
编辑提交消息,使用
git rebase--continue
继续


man git rebase
应该会有所帮助。

您可以一次压缩多组提交:

git rebase-i头~15

pick 3f3416d T11 - some issue
pick 23031eb T12 - fix
pick 8239b70 T13 - improvements 
squash e1e23fd T13 - one more fix
squash 200c8c6 T13 - last fix
pick e5b0286 T14 - great feature
pick d18bf1b T15 - removing unused files
pick a1b1821 T16 - refactor part 1.
squash dd090dc T16 - refactor part 2.
squash d87db6b T16 - refactor part 3.
pick da1dd09 T17 - new model of database
pick 39b4ace T18 - restfull api
pick 65521eb T19 - registration form
squash 8924091 T19 - login form
pick b44a25c T20 - new super feature
在重设基础期间,将询问每个组的新提交消息:

1组

# This is a combination of 3 commits.
# The first commit's message is:
T13 - improvements

# This is the 2nd commit message:

T13 - one more fix

# This is the 3rd commit message:

T13 - last fix

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Author:    Your Name <your.email@domain.com>
# ...
# This is a combination of 3 commits.
# The first commit's message is:
T16 - refactor part 1.

# This is the 2nd commit message:

T16 - refactor part 2.

# This is the 3rd commit message:

T16 - refactor part 3.

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Author:    Your Name <your.email@domain.com>
# ...
# This is a combination of 2 commits.
# The first commit's message is:
T19 - registration form

# This is the 2nd commit message:

T19 - login form

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Author:    Your Name <your.email@domain.com>
# ...
#这是3次提交的组合。
#第一次提交的消息是:
T13-改善
#这是第二条提交消息:
T13-还有一个补丁
#这是第三条提交消息:
T13-最后一次修复
#请输入更改的提交消息。行开始
#将忽略带有“#”的消息,空消息将中止提交。
#作者:你的名字
# ...
2组

# This is a combination of 3 commits.
# The first commit's message is:
T13 - improvements

# This is the 2nd commit message:

T13 - one more fix

# This is the 3rd commit message:

T13 - last fix

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Author:    Your Name <your.email@domain.com>
# ...
# This is a combination of 3 commits.
# The first commit's message is:
T16 - refactor part 1.

# This is the 2nd commit message:

T16 - refactor part 2.

# This is the 3rd commit message:

T16 - refactor part 3.

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Author:    Your Name <your.email@domain.com>
# ...
# This is a combination of 2 commits.
# The first commit's message is:
T19 - registration form

# This is the 2nd commit message:

T19 - login form

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Author:    Your Name <your.email@domain.com>
# ...
#这是3次提交的组合。
#第一次提交的消息是:
T16-重构第1部分。
#这是第二条提交消息:
T16-重构第2部分。
#这是第三条提交消息:
T16-重构第3部分。
#请输入更改的提交消息。行开始
#将忽略带有“#”的消息,空消息将中止提交。
#作者:你的名字
# ...
3组

# This is a combination of 3 commits.
# The first commit's message is:
T13 - improvements

# This is the 2nd commit message:

T13 - one more fix

# This is the 3rd commit message:

T13 - last fix

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Author:    Your Name <your.email@domain.com>
# ...
# This is a combination of 3 commits.
# The first commit's message is:
T16 - refactor part 1.

# This is the 2nd commit message:

T16 - refactor part 2.

# This is the 3rd commit message:

T16 - refactor part 3.

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Author:    Your Name <your.email@domain.com>
# ...
# This is a combination of 2 commits.
# The first commit's message is:
T19 - registration form

# This is the 2nd commit message:

T19 - login form

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Author:    Your Name <your.email@domain.com>
# ...
#这是两次提交的组合。
#第一次提交的消息是:
T19-注册表格
#这是第二条提交消息:
T19-登入表格
#请输入更改的提交消息。行开始
#将忽略带有“#”的消息,空消息将中止提交。
#作者:你的名字
# ...

谢谢,这就成功了。为了完成它,我必须
git push-f
git push-f
如果范围内的提交
8239b70
-
b44a25c
已被推送,则是必要的。如果上次推送的提交是
选择23031eb T12-fix
,这意味着,您只需更改本地历史记录。顺便说一句,如果您您必须检索旧的分支,您可以使用旧的头哈希来创建新的分支
git checkout b44a25c-b ufff\u它很好\u拥有旧的\u提交\u返回\u分支