• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Justin Joyce

Practical tips and tutorials about software development.

  • Standing Invitation
  • Featured Posts
  • Latest
  • About

Git Diff

Posted Jul 16, 2023 โ€” Updated Jan 10, 2024

When you want to compare two branches, use git diff. I usually like to pair it with the --stat option for a quick visual summary.

# Compares branch1 to branch2
git diff branch1..branch2 --stat

# By ommitting the second branch name, git assumes I mean
# "the current branch"
git diff main.. --stat

Git diff branch_name..

Let’s say I’m on a test branch, and I want to see how that branch differs from main. I can get a quick overview via git diff main.. --stat:

git diff --stat results

The regular git syntax here is git diff branch1..branch2, but by omitting branch2 git assumes I mean use the current branch.

For clarity, here’s the same comparison but with the branches in reverse order:

git diff --stat in reverse branch order

I almost always use the --stat option for a quick filename summary. There could be a big difference between branches, and I don’t want to accidentally print hundreds of lines to stdout.

Note: git diff only reads changes that have already been committed. If you have un-committed changes git diff won’t show them.

Filed Under: Git

Primary Sidebar

Recent Posts

  • Every Built-In Vim Color Scheme (with screenshots)
  • Reverse a string in Python
  • Meeting Cost Calculator
  • Vim find and replace
  • What makes an effective development team

Categories

  • Arrays (5)
  • Command Line (9)
  • Dates (3)
  • Featured (7)
  • Git (7)
  • Golang (5)
  • Javascript (8)
  • Productivity (8)
  • Projects (4)
  • Python (15)
  • Regex (2)
  • Ruby (3)
  • Shell (2)
  • Thoughts (2)
  • Tips (11)
  • Tools (3)
  • Tutorials (1)
  • Vim (4)

Archives

  • July 2024 (1)
  • February 2024 (1)
  • January 2024 (1)
  • December 2023 (1)
  • November 2023 (1)
  • October 2023 (4)
  • September 2023 (1)
  • August 2023 (2)
  • July 2023 (5)
  • June 2023 (3)
  • May 2023 (6)
  • April 2023 (5)
  • March 2023 (5)
  • February 2023 (10)
  • January 2023 (6)
  • December 2022 (7)

Copyright © 2025 ยท Contact me at justin [at] {this domain}

  • Privacy Policy