I want to compare the changes between two branches, branch_1
and branch_2
. What is the best way to view the differences using git diff between branches?
Hey! I’ve done this countless times . The easiest way to see the differences between two branches is:
git diff branch_1..branch_2
This shows all the changes that would be applied if you merged branch_2
into branch_1.
I usually run it in the terminal to get a full line-by-line view of added, removed, and modified code.
If you want a side-by-side view, you can also do:
git diff --color-words branch_1..branch_2
I love this for quickly spotting exactly what changed without scrolling through full lines.
Using git log
for a commit overview
Sometimes I just want a high-level look at what commits are different between branches. I usually do:
git log branch_1..branch_2 --oneline
This lists all commits that exist in branch_2
but not in branch_1
.
Super handy when you just want to see what features or fixes were added, without diving into the actual diffs.
I often combine it with --graph
for a visual representation:
git log branch_1..branch_2 --oneline --graph
If you prefer visuals, Git has built-in diff tools, or you can use a GUI:
git difftool branch_1..branch_2
This opens the differences in a graphical diff tool (like Meld, Beyond Compare, or VS Code).
Personally, I find it easier for reviewing big changes or when multiple files are involved.