Skip to content
LatchkeyLatchkey home

git log Command: Inspect History in CI

git log prints the commit history reachable from a starting point, in configurable detail.

CI uses git log to build changelogs, capture the latest commit message, or list commits in a release range. The format flags make its output script-friendly.

Common flags

  • --oneline - one compact line per commit (short SHA plus subject)
  • -n N / -<N> - limit output to the most recent N commits
  • --format=<fmt> / --pretty=format:<fmt> - custom output with placeholders like %H, %s, %an
  • --since / --until - filter by date range
  • <from>..<to> - show commits in a range (e.g. last tag to HEAD)
  • --no-merges - exclude merge commits

Example

shell
# Generate a changelog since the previous tag
PREV="$(git describe --tags --abbrev=0 HEAD^)"
git log --no-merges --format="- %s (%h)" "${PREV}..HEAD"

In CI

Use --format with explicit placeholders so the output stays stable for parsing across Git versions. A range like PREV..HEAD is the standard way to scope a changelog to a single release. Remember log needs real history, so shallow clones may need a deeper fetch.

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

Key takeaways

  • git log --format gives deterministic, parseable output for changelog automation.
  • A from..to range scopes history to exactly one release.
  • Changelog steps usually need full history, so deepen shallow clones first.

Frequently asked questions

git log Command: Inspect History in CI?
CI uses git log to build changelogs, capture the latest commit message, or list commits in a release range. The format flags make its output script-friendly.
In CI?
Use --format with explicit placeholders so the output stays stable for parsing across Git versions. A range like PREV..HEAD is the standard way to scope a changelog to a single release. Remember log needs real history, so shallow clones may need a deeper fetch.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card