snippetjavascriptTip
View Git commits in a specific date range
Viewed 0 times
daterangeviewgitcommitsspecific
Problem
The
Using
Moreover, to only view commits since a specific date, you can use
Similarly, if you only want to see commits up to a specific date, you can use
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.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.Moreover, to only view commits since a specific date, you can use
git log --since=<date-from>.Similarly, if you only want to see commits up to a specific date, you can use
git log --until=<date-to>.Solution
# Syntax: git log [--since=<date-from>] [--until=<date-to>]
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
# [...]Moreover, to only view commits since a specific date, you can use
git log --since=<date-from>.Similarly, if you only want to see commits up to a specific date, you can use
git log --until=<date-to>.Code Snippets
# Syntax: git log [--since=<date-from>] [--until=<date-to>]
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
# [...]# 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
# [...]# 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
# [...]Context
From 30-seconds-of-code: view-commits-in-date-range
Revisions (0)
No revisions yet.