squash commits in merge commit code example
Example 1: squash commits in git
git reset --soft HEAD~3 &&
git commit
Example 2: git merge tag to branch and squash commits
git checkout master
git merge --squash tag
git commit
git reset --soft HEAD~3 &&
git commit
git checkout master
git merge --squash tag
git commit