HACKER Q&A
📣 whoibrar

Is there something like “today X years ago” but for Git?


Google photos has something called memories [0], which shows the photos taken on a today's date but from x years ago. So, today photos from 20-Aug-2011, 20-Aug-2015, 20-Aug-2020 all show up at one place.

Since, git as a Version control system tracks changes as tiny as single character. I was wondering if there was something where I could enter a date and it will show me how the repository looked like on that particular day, or even better show how file(s) has changed in weeks, months, years and probably decades.

[0] : https://techcrunch.com/2015/08/20/google-photos-introduces-rediscover-this-day-to-help-you-reminisce/


  👤 Tomte Accepted Answer ✓
Are you looking for git checkout 'main@{1 year ago}'

See also https://git-scm.com/docs/git-rev-parse, that works with all kinds of git subcommands.

BTW, git doesn't track every change, only when you add the change.


👤 shoo
For a single file you can use `git log` to show you all patches that changed the file, going back in history forever:

  git log --follow --patch -- some/file
It composes with Tomte's @{1 year ago} tip if you want to start reading at a particular point in time:

  git log --follow --patch 'main@{1 year ago}' -- some/file
ref: https://git-scm.com/docs/git-log

👤 beverett
There is https://retrogit.com/ that sends you emails on what happened in repositories on this day, similar to memories.