Skip to content

mitchharvey/coauth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coauth

Add coauthors to your commit

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).

Usage

1. Usernames as args

$ 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.

2. No args

$ 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.

3. Amend previous commit

$ 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)

4. Additional Features

coauth -h

Use -h, or --help to see all options.

Installation

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.

Installing libgit2

First install CMake using your package manager of choice:

apt install cmake

or

brew install cmake

Then compile and install libgit2

# 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
...

Installing coauth

Note

If libgit2 is not installed, follow the above section first.

With apt (some Linux distros)

# apt install libgit2-dev # Only use this if it installs v1.5.0
apt install pkgconf
go install github.com/mitchharvey/coauth@latest

With brew (MacOS)

# brew install libgit2 # Only use this if it installs v1.5.0
brew install pkgconf
go install github.com/mitchharvey/coauth@latest

Optional Configuration

Enable Shell Completion

Coauth has shell completion integrated using cobra. Enabling completion allows you to add recently used coauthors with tab completion. coauth completion -h for more info.

Add as git sub-command

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 as git hook

Add coauth in your prepare-commit-msg hook to automatically add today's coauthors on each commit (see prepare-commit-msg).

Dependencies

Uninstalling

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.

About

Add coauthors to your git commits

Topics

Resources

Stars

Watchers

Forks

Contributors