Squashing commits using an interactive rebase
When I work on a local branch, I prefer to commit in small increments with a few comments on what I did in the commits; however, as these commits do not build or pass any test requirements, I cannot submit them for review and verification one by one. I have to merge them in my branch, and still, cherry picking my fix would require me to cherry-pick twice the number of commits, which is not very handy.
What we can do is rebase and squash the commits into a single commit or at least a smaller number of commits.
Getting ready
To get started with this example, we need a new branch, namely rebaseExample3
, that tracks origin/stable-3.1
. Create the branch with the following command:
$ git checkout -b rebaseExample3 --track origin/stable-3.1 Branch rebaseExample3 set up to track remote branch stable-3.1 from origin. Switched to a new branch 'rebaseExample3'
How to do it...
To really showcase this feature of Git, we will start by being six commits ahead of...