Tom
Tom

Reputation: 47

How to compare two git branches to get the commit hash make the difference

enter image description hereContext: I have two branches A and B working parallel with together, "git diff" or "git log" provide for me how many files have changed (the difference between two branches), but, how can I get the commit to making the difference between two branches, commit on branch A or commit on branch B, and what is commit hash?

For example, a list of the file is different between two branch
Branch A                               Branch B
File1                                   File1
File2                                   File2

I want to get commit to make difference, commit xxxxx on branch A change File1 commit yyyyy on branch B change File2

enter image description here

Upvotes: 0

Views: 2913

Answers (2)

Dev-vruper
Dev-vruper

Reputation: 430

You could try something like below

git diff branch1 branch2 -- file1

for eg: git diff master feature/xyz file1.java

For more details ,please refer to https://stackoverflow.com/a/4099805/6309111

Upvotes: 0

flyingdutchman
flyingdutchman

Reputation: 1419

I am not sure, but I think git log, which you already mentioned, can help you.

There is an option/variant, namely ..., to show the symmetric differences between 2 branches, see the man page for further information. A command to show the changing files then is:

git log --stat branchA...branchB

Upvotes: 1

Related Questions