I don’t know about you, but I love to pair program with my team members. We build a ton of features with multiple people. But is was never possible to bind multiple authors to a single commit.
But since the end of January 2018 Github came with some news about a possibility to commit with co-authors. That is awesome news Github!!
Off-course I had to check that out! And it seems pretty easy. In this blog I want to share with you how you can do that to!
Add an co-author to your commit
I’m a fan of using the terminal for git instead of a GUI. But adding a co-author can be done on both.
Terminal
On the terminal you start writing your commit message as usual. But now you add 2 empty lines and put in a row of Co-authored-by: Firstname Lastname <usernam@users.noreply.github.com>
for every co-author. After the last line of the co-author you close the message with the quotes.
> git commit -m "Your commit message
>
>
> Co-authored-by: Name <username@users.noreply.github.com>
> Co-authored-by: Name2 <username2@users.noreply.github.com>"
For every co-author you need a name, that can be a first and lastname or a name of choice. After the name you add a email address of that user between the <>
arrows.
If a co-author wil keep his/her emailadress private you can simply use the github noreply emailadress “githubusername@users.noreply.github.com”.
Git GUI and via Github website
Via a Git GUI of choice and via the Github website you can also make changes to a file. If you do that, below the file will be a field for your commit message.
Then just put in the same message as in the terminal.
Your commit message
Co-authored-by: Name <username@users.noreply.github.com>
Co-authored-by: Name2 <username2@users.noreply.github.com>"
Result
Than in your commit log on Github you will se the author and co-authors instead of only 1 author.
Thanks
If you have some additional Github tips or some questions? Please let me know on twitter 😉: @rsschouwenaar
Originally published on https://raymonschouwenaar.nl/commit-together-multiple-users-github/