Squash commits in your branch

One of the absolutely most infuriating things at work is rebasing. We're still using rebase instead of squash merge (hopefully that changes soon!) and Jenkins always thinks I have merge conflicts, even after rebasing everything. I'm probably doing something wrong, but in the meanwhile I found this gem:

git checkout yourBranch
git reset $(git merge-base master $(git branch --show-current))
git add -A
git commit -m "squashed commits"

This squashes all the commits you've made in the branch, which are not in master, into one commit. And Jenkins won't complain about any merge conflicts 🤑

If you already pushed the commits to remote you can just replace them with git push --force-with-lease


- 4 toasts