diff --git a/README.md b/README.md index ae622d7..e889db7 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ and pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud). -_890 TILs and counting..._ +_891 TILs and counting..._ --- @@ -248,6 +248,7 @@ _890 TILs and counting..._ - [Untrack A Directory Of Files Without Deleting](git/untrack-a-directory-of-files-without-deleting.md) - [Untrack A File Without Deleting It](git/untrack-a-file-without-deleting-it.md) - [Update The URL Of A Remote](git/update-the-url-of-a-remote.md) +- [Using Commands With A Relative Date Format](git/using-commands-with-a-relative-date-format.md) - [Verbose Commit Message](git/verbose-commit-message.md) - [Viewing A File On Another Branch](git/viewing-a-file-on-another-branch.md) - [What Changed?](git/what-changed.md) diff --git a/git/using-commands-with-a-relative-date-format.md b/git/using-commands-with-a-relative-date-format.md new file mode 100644 index 0000000..112b4b7 --- /dev/null +++ b/git/using-commands-with-a-relative-date-format.md @@ -0,0 +1,27 @@ +# Using Commands With A Relative Date Format + +If you want to know what changed on a branch _since_ last week, you can more or +less ask just like that: + +```bash +$ git log --since="1 week ago" +``` + +Or, what has happened since yesterday: + +```bash +$ git log --after="yesterday" +``` + +The `--since`/`--after` flags, and their counterparts `--until`/`--before`, +accept a variety of date formats including _relative dates_. + +Relative dates can be used with other commands and even as a ref modifier. For +instance, this is a way of comparing `develop` from a week ago with `develop` +from two weeks ago: + +```bash +$ git diff develop@{"1 week ago"} develop@{"2 weeks ago"} +``` + +[source](https://alexpeattie.com/blog/working-with-dates-in-git)