结合Git仓库的前两个提交? [英] Combine the first two commits of a Git repository?
问题描述
ABC
我想结合两个提交 A 和 一次提交
AB-C
我试过
git rebase -i A
这会打开我的编辑器,其内容如下:
pick e97a17b B
pick asd314f C
我将它改为
壁球e97a17b B
pick asd314f C
然后Git 1.6.0.4说:
如果没有前面的提交,不能'压扁'
或者这是不可能的?
使用 git rebase -i --root
作为Git 1.7.12版本。
在交互式rebase文件中,更改第二行提交 B 改为压扁并将其他行保留在 pick : $ b < pick f4202da A
squash bea708e B
pick a8c6abc C
这将把两个提交 A 和 B 合并为一个提交 AB 。
在这个答案中找到。
Suppose you have a history containing the three commits A, B and C:
A-B-C
I would like to combine the two commits A and B to one commit AB:
AB-C
I tried
git rebase -i A
which opens up my editor with the following contents:
pick e97a17b B
pick asd314f C
I change this to
squash e97a17b B
pick asd314f C
Then Git 1.6.0.4 says:
Cannot 'squash' without a previous commit
Is there a way or is this just impossible?
Use git rebase -i --root
as of Git version 1.7.12.
In the interactive rebase file, change the second line of commit B to squash and leave the other lines at pick:
pick f4202da A
squash bea708e B
pick a8c6abc C
This will combine the two commits A and B to one commit AB.
Found in this answer.
这篇关于结合Git仓库的前两个提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!