show commits since branch creation

Full documentation is here: https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html

Suppose you have a repo that looks like this:

base  -  A  -  B  -  C  -  D   (master)
                \
                 \-  X  -  Y  -  Z   (myBranch)

Verify the repo status:

> git checkout master
Already on 'master'
> git status ; git log --oneline
On branch master
nothing to commit, working directory clean
d9addce D
110a9ab C
5f3f8db B
0f26e69 A
e764ffa base

and for myBranch:

> git checkout myBranch
> git status ; git log --oneline
On branch myBranch
nothing to commit, working directory clean
3bc0d40 Z
917ac8d Y
3e65f72 X
5f3f8db B
0f26e69 A
e764ffa base

Suppose you are on myBranch, and you want to see only changes SINCE branching from master. Use the two-dot version:

> git log --oneline master..myBranch
3bc0d40 Z
917ac8d Y
3e65f72 X

The three-dot version gives all changes from the tip of master to the tip of myBranch. However, note that the common commit B is not included:

> git log --oneline master...myBranch
d9addce D
110a9ab C
3bc0d40 Z
917ac8d Y
3e65f72 X

PLEASE NOTE: git log and git diff BEHAVE DIFFERENTLY! The behavior is not exactly opposite, but almost:

> git diff master..myBranch
diff --git a/rev.txt b/rev.txt
index 1784810..e900b1c 100644
--- a/rev.txt
+++ b/rev.txt
@@ -1 +1 @@
-D
+Z

> git diff master...myBranch
diff --git a/rev.txt b/rev.txt
index 223b783..e900b1c 100644
--- a/rev.txt
+++ b/rev.txt
@@ -1 +1 @@
-B
+Z

So, the two-dot version shows the diff from tip of master (i.e. D) to tip of myBranch (Z). The three-dot version shows the difference from the base of myBranch (i.e. B) to the tip of myBranch (Z).


You want the double dot notation:

git log master..<your_branch_name>

I did a test with the following repo structure:

a - - c - e - - g - i   master
  \ b - d / \ f - h     test

I then tried git log master..test:

f - h

And then git log master...test:

  - g - i
  f - h

So double dot shows the commits in test but not in master (^master temp) and triple dot shows commits in master AND test but not in both.

The other excellent answer in this question got it right first and has a better explanation (https://stackoverflow.com/a/24769534/1185838); it should probably be marked as the answer instead of mine. You can also reference this answer (https://stackoverflow.com/a/463027/1185838) which helped me better understand the difference between double dot and triple dot notation.

Tags:

Git

Git Log