0

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

Tom
  • 47
  • 6
  • I don't really understand what you are asking, would you mind elaborating? In particular, what do you mean when you ask about a "commit"? Are you interested in what command you can run to apply all commits från e.g. branch B on top of branch A? – Patrick Dec 28 '20 at 09:34
  • "git log" comparing the commit differences between 2 branches, and I want to know what is commit made this difference, commit on branch A or commit on branch B made the difference between two branches. – Tom Dec 28 '20 at 09:40
  • @Tom What do you mean by "commit differences" exactly? Commits are one thing, diffs are a different thing. If you want to know which commits on branch A, unavailable on branch B touched what files you can try: `git log --stat B..A`. – Patryk Obara Dec 28 '20 at 09:43
  • Do you mean you want to list all files changed in each commit on each of the branches? Is that what you mean with "make the difference". – Patrick Dec 28 '20 at 09:45

2 Answers2

1

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
flyingdutchman
  • 1,197
  • 11
  • 17
  • How can I detect branch B added the new line or branch A has removed this line when diff two branches, and what is git revision? – Tom Dec 29 '20 at 08:46
0

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

Dev-vruper
  • 421
  • 3
  • 12