CLI tool to add coauthors to git commits, meant to be a replacement for github desktop's easy coauthor feature.
Some alternatives exist:
- git mob and git-coco, but those require you to set up configuration, and remember the initials you specified for each coauthor.
- Extensions for the github cli like gh-co-author, but I don't want to have to install the github cli.
- Other tools, such as git duet, Pivotal git pair, etc. don't support the co-authored-by string, and instead abuse other commit metadata.
Pros of coauth:
- Zero configuration necessary
- Only needs username, looks up names and emails using GitHub's API
- copying exactly the behavior of GitHub desktop, which means you get the email that the user has configured as default in GitHub
- No need to remember your coauthors' usernames, you can use tab completion to show a list of recently used coauthors
- Integrates with the prepare-commit-msg hook (see prepare-commit-msg) to add coauthor trailer without amending a previous commit (useful if you want to GPG sign your commits).
$ coauth mitchharvey alice bob
Updated today's coauthors:
Mitchell Harvey <6061049+mitchharvey@users.noreply.github.com>
Alice <95208+alice@users.noreply.github.com>
Vadym Kalion <1436+bob@users.noreply.github.com>
If usernames are passed as arguments, coauth will retrieve details for those users, set those specified coauthors as Today's Coauthors, and then will be included by default in all commits today. This resets daily.
$ coauth
Today's Coauthors:
Username Name Tally Last
mitchharvey Mitchell Harvey 3 2025-07-22T17:19:51Z
bob Vadym Kalion 0 2025-07-22T17:19:51Z
alice Alice 0 2025-07-22T17:19:51Z
All Coauthors:
Username Name Tally Last
mitchharvey Mitchell Harvey 3 2025-07-22T17:19:51Z
bob Vadym Kalion 0 2025-07-22T17:19:51Z
alice Alice 0 2025-07-22T17:19:51Z
torvalds Linus Torvalds 1 2024-09-16T04:44:05Z
By default, coauth will list Today's Coauthors, as well as all the coauthors in the db, including a tally of how many commits they have been added to, and when the last with commit was made.
$ git commit -m "commit message"
$ coauth --amend
commit message
Co-authored-by: Mitchell Harvey <6061049+mitchharvey@users.noreply.github.com>
Amend Commit? [y/N]With option --amend/-a coauth will amend the previous commit, adding the specified coauthors (or by default Today's Coauthors)
coauth -hUse -h, or --help to see all options.
Warning
Note about git2go
The latest main version of git2go only supports libgit2 v1.5.0. Most package managers do not provide this version anymore, if yours does, then congrats, you can skip this section. Otherwise I have included the following instructions to build libgit2 from source, but keep in mind this version is extremely old and maybe have issues that were fixed in versions released since. Here is a list of all commits since v1.5.0.
apt install cmakeor
brew install cmake# clone specifically v1.5.0
git clone --branch v1.5.0 https://github.com/libgit2/libgit2.git
cd libgit2
# build
mkdir build
cd build
cmake ..
cmake --build .
cmake --build . --parallel 16 # adjust to reflect desired parallelism
...- Install Go if you haven't already: instructions
- Ensure go binaries are included in your path: instructions
Note
If libgit2 is not installed, follow the above section first.
# apt install libgit2-dev # Only use this if it installs v1.5.0
apt install pkgconf
go install github.com/mitchharvey/coauth@latest# brew install libgit2 # Only use this if it installs v1.5.0
brew install pkgconf
go install github.com/mitchharvey/coauth@latestCoauth has shell completion integrated using cobra. Enabling completion allows you to add recently used coauthors with tab completion.
coauth completion -h for more info.
if you want to pretend like this is a built in feature of git, you can add it as a custom subcommand. Just add the included script (see git-co) to somewhere on your path.
For simplicity, we can install it alongside coauth:
$ chmod +x git-co
$ cp git-co $(dirname $(which coauth))
Now git co will work just like coauth:
$ git co charlie
Updated today's coauthors:
Charles Hornberger <1763+charlie@users.noreply.github.com>
$ git co -a
test
Co-authored-by: Charles Hornberger <1763+charlie@users.noreply.github.com>
Amend Commit? [y/N]
Add coauth in your prepare-commit-msg hook to automatically add today's coauthors on each commit (see prepare-commit-msg).
- Go installation instructions
- libgit2 v1.5 (for git2go v34)
- pkgconf
A sqlite database named coauth.sqlite is automatically created in a Coauth preferences directory created in the preferences directory defined by Go's os.UserConfigDir() (reference)
You can use coauth --delete-database to delete this directory and database contained inside.