Squash the last 5 commits interactively:
git rebase -i HEAD~5In the editor, change pick to squash (or s) for commits you want to fold into the previous one:
pick abc1234 Add feature
squash def5678 Fix typo
squash ghi9012 More fixes
pick jkl3456 Add testsRebase onto main before merging your feature branch:
git fetch origin
git rebase origin/mainIf something goes wrong:
git rebase --abort