2.4 Git Basics: Git show who the author and committer are?

Table of Contents

Git show

Git show is a command that displays the details of a specific commit. It shows the commit message, author, committer, date, and the changes made in the commit.

Indication of author and committer

The author is the person who originally wrote the code or made the changes while the committer is the person who added the changes to the repository. Both author and committer can be the same person or different people.

To view the author and committer of a specific commit, you can use the following command:

git show --pretty=format:"%h %an %ae %s" <commit-hash>

Here, --pretty=format:"%h %an %ae %s" specifies the format in which the output should be displayed. %h displays the abbreviated commit hash, %an displays the author name, %ae displays the author email, and %s displays the commit message.

You can also use the --author and --date options to specify the author and date of the commit while making a new commit. For example:

git commit --author="John Doe <[email protected]>" --date="2021-07-01T12:00:00" -m "Added new feature"

Here, --author specifies the author of the commit and --date specifies the date of the commit.

Output formatting

The output of the git show command can be formatted in different ways using different options. Some of the commonly used options are:

  • --abbrev-commit: Display the abbreviated commit hash instead of the full hash.
  • --pretty: Display the output in a specific format. For example, --pretty=oneline displays the output in a single line.
  • --name-only: Display only the names of the files that were changed in the commit.
  • --name-status: Display the names and status of the files that were changed in the commit.

For more options, you can refer to the Git documentation.

Conclusion

The git show command is a useful tool to view the details of a specific commit, including the author and committer. By using the various options available, you can format the output according to your requirements.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.