git: Get a diff between branches

1 min read

If you want to compare the differences between two branches on git, it's quite straightforward: We just need to tell from which branch to witch one we want to do the diff

We can tell diff to compare both branches by using three dots as follows:

$ git diff master...demo_branch
diff --git a/file b/file
index f70f10e..fc55909 100644
--- a/file
+++ b/file
@@ -1 +1,3 @@
+0
 A
+9

So, if we want to import the changes we can do it using git merge:

$ git merge demo_branch
Updating 4756e2c..2ef5f1a
Fast-forward
 file | 2 ++
 1 file changed, 2 insertions(+)

Posted on 25/06/2021

Categories