Let's assume that the feature branch is called feature
and the main branch main
:
- Create a temporary (say
temp
) branch frommain
:
git checkout -b temp main
- Squash the feature branch in:
git merge --squash feature
- Commit the changes (the commit message contains all squashed commit messages)
git commit
- Go back to the
feature
branch and point it to thetemp
branch:
git checkout feature
git reset --hard temp
- Delete the temporary branch:
git branch -d temp
- Push your changes to the remote branch
git push origin feature --force