DEV Community

Srebalaji Thirumalai
Srebalaji Thirumalai

Posted on • Originally published at gitbetter.substack.com on

How to add multiple authors to a commit in Github

multiple authors to a commit in github

This post was originally posted in the newsletter GitBetter. If you are interested in leveling up your game in Git, you can subscribe to it.

Github supports to add multiple authors to a single commit.

This feature is helpful when developers do pair programming. So it will be clear who contributed to the commit. And their contribution gets attribution in the pull request and in their contribution graph.

And moreover adding co-authors is so simple.

--

Adding co-authors

You have to mention the author’s info in the commit message as below.

<Commit message>

Co-authored-by: Jon Snow <jon@gmail.com>
Co-authored-by: Tyrian <tyrian@users.noreply.github.com>
Enter fullscreen mode Exit fullscreen mode

In the above snippet, you can see we should add Co-authored-by label. You can add multiple authors as you need.

And remember you should leave at least one line of white space.

Sometimes the author’s email address won’t be public. So Github will be providing a private email address to that user. You can use that email address too for privacy reasons.

You can see I have used a private email address for the user Tyrian

github co-author

--

In the above image, you can see I’m adding a co-author.

github co-author

And in Github you can see it’s showing two authors have contributed to the commit.

--

Using vs-code extension

If you are using vs-code then adding co-authors is much more simpler.

Git Co-Authors is a handy vs-code extension you can use to add co-authors to your repo.

github co-authors

--

git-coauthor - Simple multiple author support porcelain for git

I found another helpful tool git-coauthor which is very lightweight tool written in bash.

The usage is very simple. You can add co-authors to a list and use them as appropriate.

And it also has option to switch to solo commits and to co-authors commits easily. This is one of my personal favorite.

Github support for co-authors is a useful feature you can start using. And it comes in handy when you do pair programming.

This post was originally posted in the newsletter GitBetter. If you are interested in leveling up your game in Git, you can subscribe to it.

Top comments (0)