我正在使用git开发一个功能,目前已完成以下步骤。
我希望在合并到主分支之前压缩
我不明白为什么将
产生一个新的提交,该提交不包含上一个提交所做的更改。
他们迷失了。在合并到主分支之前,有什么帮助将所有这些提交压缩成一个单独的提交的方法吗?
- 基于
master
检出新的功能分支feature1
- 添加了几个提交。
- 基于
feature1
检出新分支test
。 - 在
test
中进行一些更改。 - 返回(checkout to)
feature1
分支。 - 将
test
分支合并到feature1
分支 - 删除
test
分支 - 编辑文件,并修改最后一个提交以反映更改
这是git log --oneline -n 5
的输出
de5d701 Merge branch 'test' into 'feature1' (amended)
a668f93 'feature1' commit3
ded7c00 'feature1' commit2
8731807 Initial 'feature1' commit
ff2f539 latest 'master' commit
我希望在合并到主分支之前压缩
ff2f539 latest 'master' commit
后的所有内容。我尝试执行此操作,但遇到了问题。git rebase --interactive ff2f539
但是最新的提交在编辑器中没有列出:
pick 8731807 Initial 'feature1' commit
pick ded7c00 'feature1' commit2
pick a668f93 'feature1' commit3
# Rebase ff2f539..de5d701 onto ff2f539
#
# Commands:
...
# Note that empty commits are commented out
我不明白为什么将
test
分支合并到feature1
分支后的最新提交被跳过了。
编辑器中的内容如下:pick 8731807 Initial 'feature1' commit
squash ded7c00 'feature1' commit2
squash a668f93 'feature1' commit3
# Rebase ff2f539..de5d701 onto ff2f539
#
# Commands:
...
# Note that empty commits are commented out
产生一个新的提交,该提交不包含上一个提交所做的更改。
de5d701 Merge branch 'test' into feature1(amended)
他们迷失了。在合并到主分支之前,有什么帮助将所有这些提交压缩成一个单独的提交的方法吗?