brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: git diff main@{yesterday} compares a branch with how it was earlier

Git
~/tips/tip-git-diff-branch-yesterday

git diff main@{yesterday} main

Uses the reflog to compare a branch with its state at an earlier time on your machine.

Git can read a branch name plus a time in braces. That makes it easy to see what changed on a branch since this morning or since last week.

git diff main@{yesterday} main

The @{...} part asks the reflog where the branch pointed at that time. Git understands a lot of forms: @{yesterday}, @{1.week.ago}, @{2.hours.ago} or a date like @{2026-11-01}. Combine it with --stat for a short list:

git diff --stat main@{1.week.ago} main

I like this after a few pulls in a row, when you want to know what came in during the week without hunting for commit hashes. It works with git log too: git log main@{yesterday}..main lists the commits that arrived since then.

The big catch: this is your local reflog, not the history of the project. It records where the branch pointed in your clone, so it only knows times when you had the repository and moved that branch. A fresh clone has almost nothing in it, and a branch that didn’t move for a month points at the same commit for every time in that month. Reflog entries also expire, after 90 days by default. For “what did the project look like on this date”, use git log --until instead.

Further reading: gitrevisions documentation, git-reflog documentation

More Git tips git show-branch main feature git log --stat -5 git merge --no-ff feature -m "Merge feature" git merge --squash feature git merge --abort All Git tips (144) All topics

Link