Best practice when merging your feature branch into master

Reading Time: < 1 minute

Keeping the master branch clean and tidy is something that I am all for. One way of accomplishing this is by having squash commits from your feature branches into master. This is done by using a combination of MERGE and REBASE.

First, we’ll rebase our feature branch to make sure all our changes are “ahead” of the master.
Checkout to the feature branch and rebase:

git checkout feature
git rebase master

Then, we’ll merge the feature into master sqashing all the commits so that we have one tidy commit on master after the merge. Checkout the master branch then squash and merge your feature:

 git merge --squash feature
git commit -m "comment here"

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *