Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show git log for only two branches?

Tags:

git

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?

like image 883
KostaZ Avatar asked Nov 06 '16 15:11

KostaZ


People also ask

Does git log show all branches?

Graph all git branchesDevelopers can see all branches in the graph with the –all switch. Also, in most situations, the –decorate switch will provide all the supplemental information in a formatted and nicely color-coded way.

How do I compare commits in two branches?

To compare any two commits in your branch, use the Ctrl key to select the two commits that you want to compare. Then right-click one of them and select Compare Commits.

Can we checkout two branches in git?

Git offers a feature referred to as a worktree, and what it does is allow you to have multiple branches running at the same time. It does this by creating a new directory for you with a copy of your git repository that is synced between the two directories where they are stored.


2 Answers

The command

git show-branch feature master

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

like image 162
Antony Hatchkins Avatar answered Sep 22 '22 00:09

Antony Hatchkins


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

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

like image 25
cerberos Avatar answered Sep 21 '22 00:09

cerberos