Easily create co‑authored commits with GitHub handles

Seth Larson @ 2025-10-24

You can add co-authors to a GitHub commit using the Co-authored-by field in the git commit message. But what if your co-author doesn't have a public email address listed on GitHub?

No problem, you can use this handy script to automatically discover a users' display name and per-account "noreply" email address that'll mark their account as a co-author without a public email address.

#!/bin/bash
login="$@"
read id display_name < <(echo $(curl -s "https://api.github.com/users/$login" | jq -r '.id, .name'))
echo "Co-authored-by: $display_name <$id+$login@users.noreply.github.com>"

I've added this script to my PATH in a file named coauthoredby, so I can call the script like so:

$ coauthoredby sethmlarson
Co-authored-by: Seth Michael Larson <[email protected]>

And this can be used auto-magically with multi line git commits, so if I'm trying to credit Quentin Pradet as a co-author I'd do this:

$ git commit -m 'Fixing bugs as usual' \
    --trailer '$(coauthoredby pquentin)'

Resulting in this git commit message:

$ git log

Author: Seth Michael Larson <[email protected]>
Date:   Fri Oct 24 11:07:55 2025 -0500

    Fixing bugs as usual

    Co-authored-by: Quentin Pradet <[email protected]>

Wow, you made it to the end!