Data report"State of code review 2024" is now liveRead the full report

How to see the time of a commit in GitHub

Kenny DuMez
Kenny DuMez
Graphite software engineer


Note

This guide explains this concept in vanilla Git. For Graphite documentation, see our CLI docs.


Understanding the timing of commits in GitHub is essential for tracking project progress, coordinating team efforts, and conducting thorough code reviews. This guide will walk you through several methods to see the time of commits in GitHub, both through the GitHub interface and using Git commands.

  1. Individual repository commits

    To view the time of a commit in a specific repository:

    • Navigate to the GitHub repository where you want to check the commit time.
    • Click on the "Commits" link located in the top bar of the repository files list. This section lists all the commits made to the repository.
    • Each commit in the list will have a relative timestamp (e.g., "2 hours ago"). For an exact time, hover over this relative timestamp, and a tooltip will appear showing the precise date and time of the commit.
  2. Commit history for a specific file

    If you want to see the commit history of a specific file:

    • Go to the repository that contains the file.
    • Navigate to the file and click on it.
    • Click the "History" button located above the file content. This will list all the commits that have modified this file.
    • Similar to the repository commit history, each entry will have a relative timestamp. Hover over the timestamp to see the exact date and time.

If you prefer to use the command line or need to script the retrieval of commit times, Git provides powerful tools to extract detailed information about each commit.

  1. Checking the commit time of a specific commit

    You can use the git show command to display detailed information about a specific commit, including its timestamp:

    Terminal
    $ git show --no-patch --no-notes --pretty='%H %cd' <commit-hash>

    Replace <commit-hash> with the actual commit ID. This command shows the commit hash and the date of the commit. The %cd placeholder specifies the commit date.

  2. Listing all commit times in a repository

    To list the times for all commits in the current branch:

    Terminal
    $ git log --pretty=format:"%h - %cd - %s"

    This command will display the commit hash, the commit date, and the commit message for each commit in the log. You can customize the date format by using the --date=format:... option with git log.

  3. Finding the commit time for a particular file

    To see the commit times for all changes to a specific file:

    Terminal
    $ git log --pretty=format:"%h - %cd - %s" -- <file-path>

    Replace <file-path> with the path to the file in your repository. This command will give you a history of commits specifically for that file, along with their timestamps.

  • Regular commits: Make regular commits with meaningful messages. This not only helps in tracking changes effectively but also makes it easier to understand the context of each change when reviewing commit times.
  • Automate reports: If you need regular reports on commit times (e.g., for daily stand-ups), consider scripting these checks using the Git command line and scheduling them as needed.

Graphite
Git stacked on GitHub

Stacked pull requests are easier to read, easier to write, and easier to manage.
Teams that stack ship better software, faster.

Or install our CLI.
Product Screenshot 1
Product Screenshot 2