Skip to content

Commit

Permalink
Storify view-commits-in-date-range
Browse files Browse the repository at this point in the history
  • Loading branch information
Chalarangelo committed Apr 1, 2024
1 parent a8d64a6 commit ffc884a
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions content/snippets/git/s/view-commits-in-date-range.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,54 @@
---
title: View commits in a specific date range
type: snippet
title: View Git commits in a specific date range
shortTitle: View commits in date range
type: story
language: git
tags: [repository,commit]
cover: organizer
dateModified: 2021-04-13
excerpt: View all commits in a specific date range using `git log`.
dateModified: 2024-03-29
---

Prints all commits in the specified date range.
The `git log` command can be used for all sorts of things, including **filtering commits** based on various criteria. One of the most common use cases is to view all **commits in a specific date range**. This can be useful when you want to see what changes were made during a specific period of time, or when you're trying to track down a bug that was introduced at a certain point in time.

- Use `git log --since=<date-from> --until=<date-to>` to view a log of all commits between `<date-from>` and `<date-to>`.
- You can use only `--since=<date-from>` to see all commits since a specific date or only `--until=<date-to>` to view all commits up to a specific date
- Use arrow keys to navigate, press <kbd>Q</kbd> to exit.
## View commits between two dates

Using `git log --since=<date-from> --until=<date-to>`, you can view all commits **between** `<date-from>` and `<date-to>`. The dates can be specified in a variety of formats, such as `YYYY-MM-DD`, `MM/DD/YYYY`, or even relative terms like `yesterday`, `2 weeks ago`, etc.

```shell
git log [--since=<date-from>] [--until=<date-to>]
# Syntax: git log [--since=<date-from>] [--until=<date-to>]

# Examples
git log --since='Apr 1 2021' --until='Apr 4 2021'
# commit c191f90c7766ee6d5f24e90b552a6d446f0d02e4
# Author: 30 seconds of code
# Date: Tue Apr 6 11:11:08 2021 +0300
# [...]
```

## View commits since a specific date

Moreover, to only view commits **since** a specific date, you can use `git log --since=<date-from>`.

```shell
# Syntax: git log --since=<date-from>

git log --since='2 weeks ago'
# commit c191f90c7766ee6d5f24e90b552a6d446f0d02e4
# Author: 30 seconds of code
# Date: Tue Apr 6 11:11:08 2021 +0300
# [...]
```

## View commits until a specific date

Similarly, if you only want to see commits **up to** a specific date, you can use `git log --until=<date-to>`.

```shell
# Syntax: git log --until=<date-to>

git log --until='yesterday'
# commit c191f90c7766ee6d5f24e90b552a6d446f0d02e4
# Author: 30 seconds of code
# Date: Tue Apr 6 11:11:08 2021 +0300
# [...]
```

0 comments on commit ffc884a

Please sign in to comment.