0 votes
1 view
in Devops and Agile by (25.5k points)

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?

1 Answer

0 votes
by (42.7k points)

Two combine the first two commits of a git repository you could use:

git rebase -i --root

This command works for versions higher than git version 1.7.12

This command will open a file in that interactive rebase file makes the second commit to stash and leave the remaining to pick as shown below according to your question.

pick f4202da A

squash bea708e B

pick a8c6abc C

This will combine the two commits A and B to one commit AB. 

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...