Give credit to your teammates when pairing or mob-programming.
co-author.webm
It's useful to know who to ask when struggling with a piece of code.
Git blame is great, but it only mentions the committer, which leaves out the pair/mob partners.
It helps to know who else was involved (maybe the committer is busy or left the company long ago).
There are plenty of editor plugins (VSCode, JetBrains) that follow GitHub's guidelines for co-authoring commits.
This is a simple CLI tool that achieves the same thing, while being editor independent and easy to integrate into your existing workflows.
cargo install co-author
Co-author will look for an authors.csv
file in your current working directory,
falling back to $XDG_CONFIG_HOME/co-author/
, $HOME/.config/co-author/
,
$HOME/.co-author/
and $HOME
in that order.
This file should follow the structure alias,name,email
:
j,John Doe,[email protected]
aj,Alice Johnson,[email protected]
bb,Bob Brown,[email protected]
e,Erica Lee,[email protected]
If no options are passed, it will prompt you for a space-separated list of aliases and then for a commit message.
It will produce a commit message with the following structure:
a commit message
Co-Authored-by: John Doe <[email protected]>
Co-Authored-by: Erica Lee <[email protected]>
If you group multiple users under the same alias, they will all be retrieved at once.
This is especially useful if you jump between various teams and would rather pick groups of people instead of individuals.
So for a file like:
j,John Doe,[email protected]
j,Jane Smith,[email protected]
When given the alias j
, it will add both users as co-authors.
You can modify the behavior in a number of ways, most will bypass the prompt:
co-author -h
Co-Author your git commits from the command line
Usage: co-author [OPTIONS]
Options:
-f, --file <FILE> CSV file containing a list of authors (alias,name,email)
-l, --list <LIST> List of comma separated author aliases
-a, --all Use all available authors
-m, --message <MESSAGE> Specify commit message
-e, --editor Open default editor for commit message
-p, --pre-populate Pre-populate prompt/editor with (first line of) last commit message
-s, --sort Sort authors signatures when adding to commit message
--amend Amend last commit, both message and authors will be overwritten
--fzf Use fzf for author selection
-h, --help Print help
-V, --version Print version
Specify a different authors file path.
Use a pre-defined alias list.
This makes the alias selection scriptable. It also helps when working with different teams.
alias coa_proj_a="co-author --list a,b,c"
alias coa_proj_x="co-author --list x,y,z"
Omits the alias prompt.
Use all the aliases in the file.
Conflicts with --list
.
Omits the alias prompt.
Just like git's -m
: Specify a commit message.
Omits the message prompt.
Just like git's default behavior: Open a text editor to write the commit message.
It will look for the editor
config in your git setup, falling back to
$EDITOR
, vim
and vi
in that order.
Omits the message prompt.
Pre-populate either the prompt or the editor with the subject of the last commit message, so only the first line is recovered.
If you use Conventional Commits or other standards you might want the same general format, just with a different type or description.
Conflicts with --message
.
Sort authors alphabetically by signature (username <email>
).
If not used it will respect the order in the authors.csv
file.
Amends the last commit, overwriting message and authors with the newly provided ones.
Enables --pre-populate
flag under the hood.
Depends on fzf
being installed.
Presents a picker for the authors using your fzf
install (and config).
Uses the --multi
flag, so pressing Tab
will select multiple authors.
Press enter when done to continue with the commit message.
fzf.webm
Conflicts with --all
and --list
.