Git: how to compare two branches

git commits

Sometimes it’s necessary to get the difference between two branches. Git already provides a really powerful diff command which does exactly this:

git diff

git diff is very powerful, as it not only compares two branches, it also allows multiple comparisons:

Show changes between the working tree and the index or a tree, changes between the index and a tree, changes between two trees, changes resulting from a merge, changes between two blob objects, or changes between two files on disk.

To compare two commits, simply use the commit hashes:

git diff 27b00e..f553c6

To compare two branches, simply use the branch names:

git diff master..feature/myNewFeature

The output looks like this:

diff --git a/lib/components/list_view/list_checkbox.dart b/lib/components/list_view/list_checkbox.dart
index 4985774..b3f5957 100644
--- a/lib/components/list_view/list_checkbox.dart
+++ b/lib/components/list_view/list_checkbox.dart
@@ -23,7 +23,7 @@ class ListCheckbox extends StatelessWidget
         checkColor: (checked && inactive) ? Colors.grey :,
         onChanged: onChanged,
         activeColor: Colors.transparent,
-        focusColor:,
+        focusColor:,

Photo by Yancy Min on Unsplash

Leave a Reply

Your email address will not be published. Required fields are marked *