Skip to content

Commit 50e1151

Browse files
committed
Add Using Commands With A Relative Date Format as a git til
1 parent 4acebbd commit 50e1151

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and pairing with smart people at Hashrocket.
99

1010
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
1111

12-
_890 TILs and counting..._
12+
_891 TILs and counting..._
1313

1414
---
1515

@@ -248,6 +248,7 @@ _890 TILs and counting..._
248248
- [Untrack A Directory Of Files Without Deleting](git/untrack-a-directory-of-files-without-deleting.md)
249249
- [Untrack A File Without Deleting It](git/untrack-a-file-without-deleting-it.md)
250250
- [Update The URL Of A Remote](git/update-the-url-of-a-remote.md)
251+
- [Using Commands With A Relative Date Format](git/using-commands-with-a-relative-date-format.md)
251252
- [Verbose Commit Message](git/verbose-commit-message.md)
252253
- [Viewing A File On Another Branch](git/viewing-a-file-on-another-branch.md)
253254
- [What Changed?](git/what-changed.md)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Using Commands With A Relative Date Format
2+
3+
If you want to know what changed on a branch _since_ last week, you can more or
4+
less ask just like that:
5+
6+
```bash
7+
$ git log --since="1 week ago"
8+
```
9+
10+
Or, what has happened since yesterday:
11+
12+
```bash
13+
$ git log --after="yesterday"
14+
```
15+
16+
The `--since`/`--after` flags, and their counterparts `--until`/`--before`,
17+
accept a variety of date formats including _relative dates_.
18+
19+
Relative dates can be used with other commands and even as a ref modifier. For
20+
instance, this is a way of comparing `develop` from a week ago with `develop`
21+
from two weeks ago:
22+
23+
```bash
24+
$ git diff develop@{"1 week ago"} develop@{"2 weeks ago"}
25+
```
26+
27+
[source](https://alexpeattie.com/blog/working-with-dates-in-git)

0 commit comments

Comments
 (0)