Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

Git Diff 2 Different Commits, Tags or Branches

blog/cards/git-diff-2-different-commits-tags-or-branches.jpg

Compare what changed between 2 points in time to help identify errors in production or evaluate changelogs.

Quick Jump: Demo Video

git diff <commit> <commit>
git diff <tag> <tag>
git diff <branch> <branch>

You can also mix and match reference types. For example you might want to see what changed between the most recent tag and the latest commit with git diff <tag> HEAD.

GitHub, GitLab and Bitbucket all have UIs to view these types of comparisons too. For example, here’s a diff between the latest 3 commits on GitHub for one of my projects which uses HEAD~3. I use this to show what changed between tagged releases in my changelog files.

Demo Video

Timestamps

  • 0:19 – One use case for this
  • 0:36 – Diffing 2 commits
  • 1:19 – Diffing 2 tags
  • 1:56 – Diffing 2 branches
  • 2:24 – Combining reference types
  • 3:07 – Comparing references on GitHub
  • 4:39 – Creating changelog links

How often do you diff things in git? Let us know below!

Never Miss a Tip, Trick or Tutorial

Like you, I'm super protective of my inbox, so don't worry about getting spammed. You can expect a few emails per month (at most), and you can 1-click unsubscribe at any time. See what else you'll get too.



Comments