4

Although I have added Co-authored-by: in the commit message, git log --name-only only shows one author, not the others, how can I make git show the coauthors?

tristone
  • 95
  • 6

3 Answers3

5

You can, in that it is a trailer:

git log --format="%h %s %an Co-author:%(trailers:key=Co-authored-by)"

While it is true Git knows nothing about it, the trailer scheme allows to add any key=value you want to the commit message.

Since Git 2.32 (Q2 2021), you can make a commit with any trailer you want.

git commit --trailer "Signed-off-by:C O Mitter <committer@example.com>" \
           --trailer "Helped-by:C O Mitter <committer@example.com>"
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
2

how can I make git show the coauthors

You can't. Git commits don't have coauthors. There is a GitHub coauthor feature, and other hosting milieus may support that sort of thing too; but Git itself knows nothing of it.

matt
  • 515,959
  • 87
  • 875
  • 1,141
0

It seems that you can’t do this with git log. But you can credit co-authors in git shortlog.

From man git shortlog:

--group=<type>

[…]

  If --group is specified multiple times, commits are counted under
  each value (but again, only once per unique value in that
  commit). For example, git shortlog --group=author
  --group=trailer:co-authored-by counts both authors and co-authors.

Commit:

commit f0897445bfe6d41ff352a7e9f352956d1ebee63d (HEAD -> main)
Author: Cristobal Hill <noreply@cribal.kz>
Date:   Wed Mar 15 22:01:53 2023 +0100

    First commit!

    Co-authored-by: Henrietta Fjord <hfj@underhillhosting.com>

With git shortlog:

Cristobal Hill (1):
      First commit!

With git shortlog --group=author --group=trailer:co-authored-by:

Henrietta Fjord (1):
      First commit!

Cristobal Hill (1):
      First commit!
Guildenstern
  • 2,179
  • 1
  • 17
  • 39