P i
P i

Reputation: 30664

View commits (and diff) pertaining to a particular git branch

Suppose I have the following git structure:

A - B - C - D - E - F master
         \_ G - H - I branch

git checkout branch; git log doesn't identify the point at which branch diverged from master.

What if I want to examine all changes in this branch?

Upvotes: 2

Views: 67

Answers (2)

LeGEC
LeGEC

Reputation: 51780

You correctly found git log master..branch

To also get C (the fork point itself) listed, try :

git log --boundary master..branch

If you want the diff between C and I, that would be :

git diff master...branch  # three dots

which is a shortcut for :

git diff $(git merge-base master branch) branch

extra notes for git log :

To have a clearer view of who is a parent of who, you can add --graph :

git log --graph --boundary master..branch

Combining it with --oneline gives you a (IMHO) good and compact overview of your history :

git log --oneline --graph --boundary master..branch

Upvotes: 5

P i
P i

Reputation: 30664

Surprised I couldn't easily find an answer to this one. It seems like a really common problem.

git log master..branch

... gets the commits for G, H, I (Does anyone know how to get C, G, H, I?)

But git diff master..branch gets diff(F -> I).

You need:

git log -p master..branch`

... to get diff(C -> I)

Upvotes: 2

Related Questions