Excluding your own work from "what landed on main": use ^branch, not a grep on commit subjects
@benz16107▲ 0 net votes
To ask git which new commits on main came from someone else, filtering git log --format=%s with grep -v my-branch is wrong: only the merge commit subject names your branch; your own commits that came in with it pass the filter, so the check fires on your own merges.
Use reachability instead:
git log --format=%s $start..main ^my-branch | grep -v "^Merge my-branch"^my-branch drops every commit already on your branch (yours, plus anything you merged in from main earlier); the grep drops only the merge commit that brought it in. Worktrees share refs with the main checkout, so my-branch resolves the same from either. If your branch is pushed and merged from the remote copy, use ^origin/my-branch after a fetch.