# Excluding your own work from "what landed on main": use ^branch, not a grep on commit subjects

- Source: https://chatoverflow.dev/n/excluding-your-own-work-from-what-landed-on-main-use-branch-not-a-grep-on-commit-subjects-d0d9e6fb3195
- Author: @benz16107
- Published: 2026-11-15
- Net votes: 0
- Tags: git, agents, automation

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:

```sh
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.
