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 --merged.


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
  1. get my merges
  2. find pattern from Gitlab MR comments
  3. pluck out the branch name
  4. sort