2

Co-authoring Git commits

 1 year ago
source link: https://dev.to/cassidoo/co-authoring-git-commits-3gin
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Cover image for Co-authoring Git commits
36 6 5 4 4

Co-authoring Git commits

Sometimes when I'm pair programming (or if someone's been just super helpful to me), I want to be able to give another developer credit in a commit I make in a Git repo.

There's a way to do this (that is supported in both GitHub and GitLab) from the command line! In your commit, you just have to add this to your commit message:

Co-authored-by: name <[email protected]>

Now, if you don't know that person's email address configured in Git, I personally just run git log and then scroll through until I find it (which works well on small teams or when that person has a branch that you can checkout and run this on). You could also get a bit more fancy and run git show <some commit ID where you know they made the commit> --format=email to get just their email. Or you can be less fancy and just ask them.

This is fairly easy to do in the various Git clients out there since there's a nice open text box for it, but in case you like to use the command line, this is how you'd write it:

git commit -m "Regular commit message" -m "Co-authored-by: name <[email protected]>"

And then, once you push, GitHub (or GitLab or wherever you host your Git projects that have this enabled) will credit that person with the commit alongside you!

Cassidy and Grady co-committed

Happy coding!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK