From fb79ce1f14cbb21fc7ce409e2ec871a0e926679a Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Wed, 15 Feb 2023 13:22:44 -0600 Subject: [PATCH] Add Review Commits From Before A Certain Date as a Git TIL --- README.md | 3 +- ...view-commits-from-before-a-certain-date.md | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 git/review-commits-from-before-a-certain-date.md diff --git a/README.md b/README.md index dec9a71..123cb75 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). -_1283 TILs and counting..._ +_1284 TILs and counting..._ --- @@ -304,6 +304,7 @@ _1283 TILs and counting..._ - [Renaming A Branch](git/renaming-a-branch.md) - [Resetting A Reset](git/resetting-a-reset.md) - [Resolve A Merge Conflict From Stash Pop](git/resolve-a-merge-conflict-from-stash-pop.md) +- [Review Commits From Before A Certain Date](git/review-commits-from-before-a-certain-date.md) - [Run A Git Command From Outside The Repo](git/run-a-git-command-from-outside-the-repo.md) - [Set A Custom Pager For A Specific Command](git/set-a-custom-pager-for-a-specific-command.md) - [Shorthand To Force Push A Branch](git/shorthand-to-force-push-a-branch.md) diff --git a/git/review-commits-from-before-a-certain-date.md b/git/review-commits-from-before-a-certain-date.md new file mode 100644 index 0000000..ce8d214 --- /dev/null +++ b/git/review-commits-from-before-a-certain-date.md @@ -0,0 +1,28 @@ +# Review Commits From Before A Certain Date + +I was recently looking at data in a 3rd-party tool and saw that there was a +very distinct shift in what was being recorded a couple years prior on a +specific date. I wanted to see what changes had been made to the codebase a day +or two before the shift. + +Rather than scrolling all the way back in `git log`, I can tell `git log` to +show me all commits from before a certain date. + +Let's say that date of interest is May 1st, 2021. I can use the `--until` flag +with `git log`. However, I should note that `--until` is an exclusive range, so +I'll need to specify `May 2 2021` if I want to start seeing commits on May 1. + +```bash +$ git log --until='May 2 2021' +``` + +Because `git log` shows commits in reverse chronological order, I'll start +seeing commits from May 1st and then as I scroll, I'll see older and older +commits. + +From here I can scan commits messages and look for one that I want to dig into. +I'd then use `git show ` to explore a specific one further. + +This is synonymous with `--before`. + +See `man git-log` for more details.