I always prefer to rebase -i
my changes locally and leave a very clean and useful commit history for my feature branches. This also have the benefit of being able to prune local/remote branches after they are merged into main (or master) with total confidence by using branch -d
.
For example, I use the following alias/macro after merging a branch without squashing it:
# ~/.gitconfig file snippet
[alias]
cleanmerged = "!git branch --merged | grep -v '*' | xargs -n 1 git branch -d"
But, when working with projects where the team just YOLO their commits and then require the unsightly mess to be squash-merged by having it be mandatory on github, I am not sure how to confidently clean local branches so I end up just leaving everything around, which makes clean up even less-certain later on as it depends on memory.
Is there any way to fix this? any incantation that will check if the squashed branches are already present in main (or master) with confidence?