Skip to content

<git-log>

Render commit history from a public GitHub, GitLab.com, or Bitbucket Cloud repository. See supported Git hosts for accepted repository URL formats and API limits.

Branch history

A single revision accepts a branch, tag, or full commit ID. This live example reads the latest three commits from git-elements.js:

html
<git-log
  repository="https://github.com/erkde/git-elements.js"
  revisions="main"
  max-count="3"
></git-log>
Loading repository history…Repository history is unavailable.

By default, <git-log> renders regular git log-style commit details, including the full hash, author, date, and complete commit message. Add oneline to use the compact format:

html
<git-log
  repository="https://github.com/erkde/git-elements.js"
  revisions="main"
  max-count="6"
  oneline
></git-log>
Loading repository history…Repository history is unavailable.

Revision sets

Revision sets follow git log semantics and use Git's own notation rather than provider-specific attribute names.

Two-dot

A..B shows commits reachable from B but not from A. This live example shows the commits added between the first two published releases:

html
<git-log
  repository="https://github.com/erkde/git-elements.js"
  revisions="v0.1.0..v0.1.1"
></git-log>
Loading repository history…Repository history is unavailable.

Three-dot

A...B shows commits reachable from either revision but not both:

html
<git-log
  repository="https://github.com/owner/project"
  revisions="main...feature"
  left-right
></git-log>

left-right marks commits unique to the first revision with < and commits unique to the second with >. It only affects symmetric three-dot logs.

Limits

The element returns at most 30 commits by default. Use max-count to request between 1 and 100, matching Git's --max-count concept.

The current implementation supports hosted public repositories only. It does not interpret local-only names such as HEAD, origin/main, reflog expressions, or unpushed commits.

API

Attributes

NameTypeDescription
repositorystringPublic repository URL.
revisionsstringBranch, tag, commit ID, or two-dot or three-dot revision set.
max-countnumberMaximum number of commits to display, from 1 to 100.
left-rightbooleanMark each side of a symmetric three-dot revision set.
onelinebooleanUse a compact one-line entry for each commit.
theme"light" | "dark"Override the operating-system color preference.

Properties

NameTypeDescription
repositorystringPublic repository URL used to load commit history.
revisionsstringBranch, tag, commit ID, or two-dot or three-dot revision set.
maxCountnumberMaximum number of commits to display, from 1 to 100.
leftRightbooleanWhether symmetric three-dot results identify their revision side.
onelinebooleanWhether to use the compact one-line commit format.
commitsreadonly GitLogCommit[]Normalized commits currently displayed by the element. Read-only.

Methods

NameReturnsDescription
reload()Promise<void>Bypass cached data and request the log again.

Slots

NameDescription
loadingContent shown when loading exceeds the configured delay.
errorContent shown when repository history cannot be loaded.

Events

NameTypeDescription
loadEventFired after repository history loads and renders.
errorEventFired when repository history cannot be loaded.

CSS custom properties

NameDefaultDescription
--git-log-bg#f5f5f4Component background color.
--git-log-text-color#292524Primary text color.
--git-log-border-color#d6d3d1Border color.
--git-log-muted-color#78716cMuted author, date, and side-marker color.
--git-log-link-color#006d8fCommit hash link color.
--git-log-left-color#b4232cLeft revision marker color.
--git-log-right-color#167044Right revision marker color.
--git-log-hover-bgrgba(41, 37, 36, 0.045)Commit hover background.
--git-log-font-familyui-monospace, monospaceComponent font family.
--git-log-font-size12pxComponent font size.
--git-log-line-height20pxCommit line height.
--git-log-loading-delay150msDelay before slotted loading content appears.

CSS parts

NameDescription
listOrdered list containing the commits.
commitA rendered commit.
sideRevision-side marker.
side-leftMarker for a commit unique to the left revision.
side-rightMarker for a commit unique to the right revision.
hashAbbreviated commit hash.
messageFirst line of the commit message.
authorCommit author name.
dateCommitter date.
loadingLoading-state container.
errorError-state container.

Exports and registration

NameKindModule
<git-log>Custom element registration@erkde/git-elements
GitLogElementClass@erkde/git-elements/components/git-log

See loading and errors for states and events, repository caching for request sharing and stored results, and styling for custom properties and CSS parts.

Released under the Apache-2.0 License.