Suppose I have the following history in my repo:
git log --oneline
<3rd sha1> Third commit.
<2nd sha1> Second commit.
<1st sha1> First commit.
How do I squash the third commit to the first one leaving the second untouched?
I have done this:
git rebase -i HEAD~3
.Edited to:
pick <2nd sha1> Second commit.
pick <1st sha1> First commit.
squash <3rd sha1> Third commit.
Solved the coflict: error: could not apply <2nd sha1>... Second commit.
.
git rebase --continue
.error: could not apply <1nd sha1>... First commit.
.git rebase --continue
.First commit (squashed).
).Then it was done.
git log --oneline
:
git log --oneline
<2nd sha1> Second commit.
<1st sha1> First commit (squashed).
I managed to do it successfully, the conflicts that occurred was supposed to happen and was easy to solve.
I am pretty satisfied with the result, but I would like to know anyway if there is any better way do achieve this.