How to add multiple authors to a commit in Github
How to use Github's multiple co-authors feature
Hey there! I’m Srebalaji. You are receiving this email because you have subscribed to level up your game in Git.
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>
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
In the above image, you can see I’m adding a 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 simplier.
Git Co-Authors is a handy vs-code extension you can use to add co-authors to your repo.
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 appropiate.
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.
That’s it for today :)
If you want me to cover any specific topics let me know.
See you next week :) :)
Even more useful features for programmers can be found here https://www.momnet.com/. Read, use and increase your competence in the field!