结合Git仓库的前两个提交? [英] Combine the first two commits of a Git repository?

查看:117
本文介绍了结合Git仓库的前两个提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设你有一个包含三个提交的历史,B 和

  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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆