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?
`git log --name-only` show coauthors
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 <[email protected]>" \
--trailer "Helped-by:C O Mitter <[email protected]>"
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 <[email protected]>
Date: Wed Mar 15 22:01:53 2023 +0100
First commit!
Co-authored-by: Henrietta Fjord <[email protected]>
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!
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.
© 2022 - 2024 — McMap. All rights reserved.