Git:如何挤压合并提交之间的提交? [英] Git: How to squash commits which have merge-commit in between?
问题描述
- 进行了多次提交。压扁提交。
- 将更改推送到远程分支。有冲突。
- 合并主要更改,功能分支上已解决的冲突。 (git fetch origin master> git merge FETCH_HEAD>手动解决了冲突> git commit> git push)
- 我做了一个更多的提交
因此,当前的提交历史记录如下所示。
从当前到旧:
$ b
- 提交3
- 提交M yyy(合并)
- 提交2
在合并我的特性之前,我如何压扁3以上提交到1分支去掌握?
您可以< master
)的提交。当你到达合并提交时解决冲突。
因此,如果您的历史记录看起来像
* D提交3(HEAD)
* M合并
/ |
| * C提交2
* | B提交master
| /
* A(master)
从> git rebase - 我会看到
master
和 your_branch
的提交列表,但不是合并提交。 pick
第一个( B
或 C
,取决于时间)和 squash
其余。
I am working on a feature branch.
- Made several commits. Squashed commits.
- Pushed changes to remote branch. Got conflicts.
- Merged changes from master, resolved conflicts on feature branch. (git fetch origin master > git merge FETCH_HEAD > resolved conflicts manually > git commit > git push)
- I made one more commit.
So, current commit history looks like this. From current to old:
- commit 3
- commit M yyy (Merged)
- commit 2
How do I squash above 3 commits into 1 before I merge my feature branch to master?
You can rebase -i
starting with commit 2
's parent (that is, the commit on master
that you branched from. You'll likely have to re-resolve conflicts when you get to the merge commit.
So if your history looks like
* D commit 3 (HEAD)
* M merge
/|
| * C commit 2
* | B commit on master
|/
* A (master)
Start with git rebase -i A
. You'll see a list of commits including both master
and your_branch
, but not the merge commit. pick
the first one (B
or C
, depending on timing) and squash
the rest.
这篇关于Git:如何挤压合并提交之间的提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!