finding notes
Show all abbreviated commits with notes for all commits on master that have notes:
git notes |\
awk '{if (!system("git merge-base --is-ancestor "$2" master")) {print $2}}' |\
xargs git show --abbrev-commit --oneline -s --notes
How does it work?
git notes
lists a mapping of note blob to target commit:
$ git notes
579c5b129af5662ca2ae6d08977fd5acfe4ca383 3c4f076572612726808d686d04acb2266401c2f9
63a79274ee3486213d58eef8a5a6f604f7c1fdb1 6546d605b21bb92f270af61f3cc00ff2978001e2
so you can filter the commits in your stream by testing each for branch membership.
But the cost of all those individual commands will really add up if you have a lot of notes.
Per-branch notes
In future what you might want to do here is use different notes refs for different branches. I don't see a way to bind the core.notesRef
configuration option to the current branch though, so you'd have to
git notes --ref "my-branch-name" --edit
etc. But you could probably
alias gn git notes --ref "$(git rev-parse --abbrev-ref HEAD)"
to deal with that.
This won't sort your current notes by branch, but it'll help in future.
You'll need to configure the refs/notes/branchname"
for each
branchname
to be fetched and pushed if you want to share them.