To show the author of each commit in a Git log, you can use the command:
git log --pretty=format:"%h - %an, %ar : %s"
Here's a breakdown of the format string used:
- %h: Abbreviated commit hash
- %an: Author name
- %ar: Author date, relative (e.g., "2 weeks ago")
- %s: Commit message
This command will present a log of commits that includes the abbreviated hash, the author's name, how long ago the commit was made, and the commit message.
If you want to see the complete list of available placeholders, you can check the git log documentation by running:
git help log
Alternatively, if you want a more concise log with each commit on a single line showing the author, you can simplify the format:
git log --oneline --author
This will provide a simple one-line summary of each commit with the commit hash and message, but it will not explicitly show the author in this format. For custom formats, stick with the --pretty=format: option.