paint-brush
How to Use Git to See Recent Changes in a Specified Time Periodby@smpnjn
480 reads
480 reads

How to Use Git to See Recent Changes in a Specified Time Period

by Johnny SimpsonAugust 29th, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Git log allows you to view the last 2 weeks of changes to your repository. The date for the `--since` variable can be given like `2 weeks ago, 1 year ago, or 2 months ago or 5 days ago. You can also use ISO timestamps, such as `2022:32:12-03-03:00' The only difference between `git whatchanged` and `git log` is that it shows all files in a change by default. Other Git Log Options can add more information to the log.
featured image - How to Use Git to See Recent Changes in a Specified Time Period
Johnny Simpson HackerNoon profile picture

Have you ever gone on a long holiday and wanted to check the updates your team has made since 2 weeks ago? Or maybe even in just the last week. Sure, you could trawl through PRs, but there may be an easier solution. Git has built-in functionality to check just this.


If you want to view the last 2 weeks of changes, you can use git log. For example, to view the last two weeks of changes to your repository, run the following in the terminal:


git log --since='2 weeks ago'


Similarly, if you only wanted to view one week of changes, you'd write:


git log --since='2 weeks ago'


The date for the --since variable can be given like 2 weeks ago, 1 year ago, 2 months ago, or 5 days ago - so you have a lot of flexibility as to how you want to show the changes. You can also use ISO timestamps, such as 2022-03-03T14:32:12-01:00


Note: you can also use git whatchanged, which does exactly the same thing as git log, but is kept around for historical reasons. The only difference between git whatchanged and git log is that git whatchanged shows all files in a change by default.


It is recommended to use git log instead, it's still possible to show all files using this command too, by typing git log --since='2 weeks ago' --stat

Other Git Log Options

As well as being able to give you a simple interface to view changes, there are some useful features git log has which can add more information to the log you receive. Here are some of my favorites:


  • --max-count or -n - limits the maximum count of git commits - can be used like git log --since='2 weeks ago' --max-count=5


  • --author or --committer - shows commits by a specific author, i.e., git log --since='2 weeks ago' --author="joe"


  • --merges or --no-merges - it either shows only merges or hides all merges.


  • --grep - limits the log by log item, so git log --since='2 weeks ago' --grep="feat-ui"will only show changes with 'feat-ui'.


  • --stat - lists all the files made in a particular change.


  • -p - which shows file-by-file changes.