git-check-mailmap - Linux


Overview

git-check-mailmap is a git command used to check for contributor information in the local git commit message, which is most useful in repositories that adopt the "commit-by-email" workflow. It validates whether the email address associated with the commit matches the author’s information maintained in the .mailmap file.

Syntax

git check-mailmap [--allow-missing] [--prep] [-f|--force] [commit-ish]

Options/Flags

  • –allow-missing: Ignore missing .mailmap file.
  • –prep: Prepare the commit message by adding a Co-authored-by tag.
  • -f, –force: Force the check even if the commit message is not signed.

Examples

Validate a Local Commit

git check-mailmap

Prepare a Commit Message with Co-Author Tag

git check-mailmap --prep

Force Validation of an Unsigned Commit

git check-mailmap -f HEAD~1

Common Issues

Missing .mailmap File

If the .mailmap file is missing, git-check-mailmap will exit with an error unless --allow-missing is specified.

Mismatched Email Addresses

If the email address in the commit message does not match the .mailmap file, git-check-mailmap will raise an error.

Integration

git-check-mailmap is often configured as a pre-commit hook to ensure that contributor information is properly recorded in commit messages.

Related Commands

  • git-commit – Commit changes to the local repository.
  • git-format-patch – Format a patch from a commit.
  • git-send-email – Send a commit as an email.