Shaohao
Shaohao

Reputation: 3511

How to squash commits after merge branches in Git?

I developed a new feature in a newFeature branch. And I had merged the branch to master branch before I squash the commits on the newFeature branch.

My commits history on master branch: enter image description here

I had tried command git rebase -i origin/master, the file looks different compare to the example from this post. According to the answer from the post, it should look similar like the following :

pick 16b5fcc Code in, tests not passing
pick c964dea Getting closer
pick 06cf8ee Something changed
pick 396b4a3 Tests pass
pick 9be7fdb Better comments
pick 7dba9cb All done

Because in the VIM, I don't see anything look like this at all as you can see in the picture.
Do I have to manually type the the pick ... in the VIM between the rebase ... line and Commonds: line?

enter image description here

I also read the post Squash my last X commits together using Git in case git rebase is not working for me. I am wondering if git reset --hard and git merge --squash commands can solve my case or not.

When I do git log, I am able to see the commits.

Question:

How can I squash the commits from the first commit aab9e06 to commit e8abbb0?

Upvotes: 4

Views: 5704

Answers (1)

Eric
Eric

Reputation: 71

Almost there, you just need to specify which commit you want to use for the rebase. So in your case it would look like:

git rebase -i aab9e06

Upvotes: 2

Related Questions