If your team squashes commits on merge because they’re scared of having a meaningful Git history (rant omitted), you may end up with a bunch of orphaned local branches.
Git can’t tell that they are already into a main branch because squashing
rewrites history. This means
git branch --contains doesn’t help, nor does
So here’s a helper to look at all your recent merges and pluck out the branch name.
git log --merges --author=jeremy --since '2 weeks' \ | grep "Merge branch '.*' into 'develop'" \ | ack -o '(PIE-\d+.*?)(?=\')' \ | sort -u
- get my merges
- find pattern from Gitlab MR comments
- pluck out the branch name