首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >压缩组推提交

压缩组推提交
EN

Stack Overflow用户
提问于 2015-07-28 23:05:22
回答 2查看 496关注 0票数 2

The answer here很好地解释了在最后几次提交已经被推送之后,如何压缩它们,但是最后12次如何压缩成三组四组呢?也就是说,我推动了提交1-12,并希望现在把他们压缩到三次提交。这三个压缩提交将分别包含原始提交1-6、7-8和9-12。我该怎么做?

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

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-07-29 06:49:46

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

git重碱-i头~15

代码语言:javascript
复制
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群

代码语言:javascript
复制
# 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>
# ...

2群

代码语言:javascript
复制
# 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>
# ...

3群

代码语言:javascript
复制
# 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
EN

Stack Overflow用户

发布于 2015-07-28 23:08:43

使用git rebase -i [commit-preceding-ones-you want-to-squash

标记您想压缩s (用于南瓜)和希望保留e用于编辑的内容。

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

man git rebase应该能帮上忙。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31688620

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档