KostaZ
KostaZ

Reputation: 798

How to show git log for only two branches?

I want to browse git history (in bash terminal) of only specific git branches. This scenario is pretty frequent use case, because people do want to compare their "feature" branch with the "master" branch.

Naively, I tried:

git log --oneline --decorate --graph --branches=feature/my_cool_feature

But even in this case I see all the other branches.

Can anyone help with the git command (in bash terminal) to show the graph of git history for only the specified branches?

Upvotes: 9

Views: 5354

Answers (3)

Tim Baverstock
Tim Baverstock

Reputation: 570

This seems to work for me:

git log --first-parent --graph --decorate 21547ed HEAD

I don't know when --first-parent appeared, or whether it's exactly right, but it cuts out 2899827383 vertical ASCII art lines.

Upvotes: 1

cerberos
cerberos

Reputation: 8035

I think this is the command you're looking for.

git log --oneline --graph --decorate somebranch otherbranch

Upvotes: 9

Antony Hatchkins
Antony Hatchkins

Reputation: 34014

The command

git show-branch feature master

will show commits that only exist in either master or feature but not both.

Upvotes: 7

Related Questions