Skip to content
LatchkeyLatchkey home

git interpret-trailers: Usage, Options & Common CI Errors

git interpret-trailers reads and writes the key/value footers at the end of commit messages.

Trailers like Signed-off-by, Reviewed-by, or Co-authored-by power DCO checks and changelog tooling. This command adds or extracts them deterministically, which makes it ideal for commit hooks and CI.

What it does

git interpret-trailers parses the trailer block at the end of a commit message and can add, replace, or normalize trailers according to configured rules, reading the message from a file or standard input.

Common usage

Terminal
git interpret-trailers --trailer "Signed-off-by: A <a@x.io>" msg.txt
git interpret-trailers --parse < commit-msg.txt
git log -1 --format=%B | git interpret-trailers --parse
echo "msg" | git interpret-trailers --trailer "Reviewed-by: B <b@x.io>"

Options

FlagWhat it does
--trailer <token>=<value>Add a trailer
--parseOutput only the parsed trailers
--if-exists <action>addIfDifferent / replace / doNothing
--if-missing <action>add / doNothing when absent
--in-placeEdit the file in place

Common errors in CI

A common DCO failure is a missing Signed-off-by trailer; pipe the message through --parse and assert the token exists. Note that lines must form a valid trailer block (no blank lines inside it) or --parse returns nothing, which scripts can misread as "no sign-off".

Using this in CI

CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.

.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0   # history, tags, and git describe all need this

- run: |
    git rev-parse --is-shallow-repository   # expect false
    git rev-parse --abbrev-ref HEAD          # prints HEAD when detached

Frequently asked questions

git interpret-trailers: Usage, Options & Common CI Errors?
Trailers like Signed-off-by, Reviewed-by, or Co-authored-by power DCO checks and changelog tooling. This command adds or extracts them deterministically, which makes it ideal for commit hooks and CI.
What it does?
git interpret-trailers parses the trailer block at the end of a commit message and can add, replace, or normalize trailers according to configured rules, reading the message from a file or standard input.
Common errors in CI?
A common DCO failure is a missing Signed-off-by trailer; pipe the message through --parse and assert the token exists. Note that lines must form a valid trailer block (no blank lines inside it) or --parse returns nothing, which scripts can misread as "no sign-off".

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card