Git file history

Tier: Free, Premium, Ultimate Offering: GitLab.com, Self-managed, GitLab Dedicated

Git file history provides information about the commit history associated with a file:

A list of 3 commits for a single file, with the newest commit marked as 'Verified'.

Each commit shows:

  • The date of the commit. GitLab groups together all commits made on the same day.
  • The user’s avatar.
  • The user’s name. Hover over the name to see the user’s job title, location, local time, and current status message.
  • The date of the commit, in time-ago format. To see the precise date and time of the commit, hover over the date.
  • If the commit is signed, a Verified badge.
  • The commit SHA. GitLab shows the first 8 characters. Select Copy commit SHA () to copy the entire SHA.
  • A link to browse () the file as it appeared at the time of this commit.

GitLab retrieves the user name and email information from the Git configuration of the contributor when the user creates a commit.

View a file’s Git history in the UI

To see a file’s Git history in the UI:

  1. On the left sidebar, select Search or go to and find your project.
  2. Select Code > Repository.
  3. Go to your desired file in the repository.
  4. In the upper-right corner, select History.

In the CLI

To see the history of a file from the command line, use the git log <filename> command. For example, to see history information about the CONTRIBUTING.md file in the root of the gitlab repository, run this command:

$ git log CONTRIBUTING.md

commit b350bf041666964c27834885e4590d90ad0bfe90
Author: Nick Malcolm <nmalcolm@gitlab.com>
Date:   Fri Dec 8 13:43:07 2023 +1300

    Update security contact and vulnerability disclosure info

commit 8e4c7f26317ff4689610bf9d031b4931aef54086
Author: Brett Walker <bwalker@gitlab.com>
Date:   Fri Oct 20 17:53:25 2023 +0000

    Fix link to Code of Conduct

    and condense some of the verbiage

Troubleshooting

Limit history range of results

History

When reviewing history for old files, or files with many commits, you can limit the search results by date. Limiting the dates for commits helps fix commit history requests timeouts in very large repositories.

In the GitLab UI, edit the URL. Include these parameters in YYYY-MM-DD format:

  • committed_before
  • committed_after

Separate each key-value pair in the query string with an ampersand (&), like this:

?ref_type=heads&committed_after=2023-05-15&committed_before=2023-11-22

The full URL to the range of commits looks like this:

For example:

https://gitlab.com/gitlab-org/gitlab/-/commits/master/CONTRIBUTING.md?ref_type=heads&committed_after=2023-05-15&committed_before=2023-11-22