from Hacker News

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

by whoibrar on 8/20/22, 4:10 PM with 4 comments

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/

  • by Tomte on 8/20/22, 4:25 PM

    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.

  • by shoo on 8/20/22, 7:53 PM

    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
  • by beverett on 8/20/22, 5:56 PM

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