brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: git commit with trailer adds Co-authored-by lines the right way

Git
~/tips/tip-git-commit-trailer-co-author

git commit -m "Add export button" \

Adds trailer lines like Co-authored-by to a commit message in the format tools expect.

When you pair with someone, their name belongs on the commit too. GitHub reads a Co-authored-by line for that, and git has an option that puts it in the right place.

git commit -m "Add export button" \
  --trailer "Co-authored-by: Bob <[email protected]>"

Trailers are the Key: value lines at the very end of a commit message, after a blank line. --trailer adds one for you, with the blank line and the spacing done right, which is the part I think is easiest to get wrong by hand. You can repeat it for more people or other keys:

git commit -m "Fix login" --trailer "Reviewed-by: Eve <[email protected]>" --trailer "Fixes: #123"

Git can also read them back out. git log --format='%(trailers:key=Reviewed-by,valueonly)' prints only the reviewers, which makes simple statistics or release notes easy.

GitHub shows extra avatars for Co-authored-by trailers, but only when the email belongs to a GitHub account, so use the address that person uses there. A noreply address works too.

Be careful with git commit --amend afterwards: if you edit the message and type text after the trailers, they’re no longer the last paragraph and tools stop seeing them. Keep them as the final block.

Further reading: git-commit documentation, git-interpret-trailers documentation, GitHub: creating a commit with multiple authors

Going deeper: Moving on from hdtv: how to export your TV show list to Trakt.tv

More Git tips git show-branch main feature git log --stat -5 git merge --no-ff feature -m "Merge feature" git merge --squash feature git merge --abort All Git tips (144) All topics

Link