Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find difference between 2 remote branches

Tags:

git

How can I find out what are the differences between 2 remote branches?

I tried:

git diff --name-status remotes/branch-V4.4..remotes/branch-V4.2

But it gives me a list of files which changes. Is there a way I get a list of commits which shows me the difference between 2 branches?

Thank you.

Update:

Thank you for the answer. I have tried 'git log --graph remotes/branch-V4.4...remotes/branch-V4.2'

I see

* commit ............
|
|
| 
* commit .............
|
|
| 
* commit .............|
|
| 
* commit .............

Why only "|" , a straight line? why it does not show where does the 2 branches begins to diverge?

Thank you.

like image 437
michael Avatar asked Dec 20 '12 22:12

michael


People also ask

How do I tell the difference between local master and remote master?

You can git branch -a to list all branches (local and remote) and then choose the branch name from the list (just remove remotes/ from the remote branch name. Example: git diff main origin/main (where "main" is the local main branch and "origin/main" is a remote, namely the origin and main branch.)

How do I compare two branches in Sourcetree?

Another way to do this is to right-click on a branch and select the "Diff against current" context menu command (current refers to the branch you are currently working on). This will give you the diff between the head commits of the two branches.


2 Answers

What you are looking for is probably something like:

gitk --left-right remotes/branch-V4.4...remotes/branch-V4.2

or if gitk is not available:

git log --oneline --graph --decorate --left-right --boundary --date-order remotes/branch-V4.4...remotes/branch-V4.2

You might also want to try it without the --date-order, but especially in complicated situations, I found that git log produces more useful graphs with that option.

Every commit in that graph will be either marked with <, > or o - that means that they are part of the left branch, the right branch or a “boundary commit”.

like image 156
Chronial Avatar answered Oct 08 '22 10:10

Chronial


Use git log instead of git diff:

git log remotes/branch-V4.4..remotes/branch-V4.2
like image 44
Andrew Marshall Avatar answered Oct 08 '22 10:10

Andrew Marshall