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"