如何比较两个 git 分支以获取提交哈希有所不同

时间:2020-12-28 09:25:45

标签: git

enter image description here上下文: 我有两个分支 A 和 B 并行工作, “git diff”或“git log”为我提供了多少文件发生了变化(两个分支之间的差异), 但是,我怎样才能获得在两个分支之间做出差异的提交,在分支 A 上提交或在分支 B 上提交,以及什么是提交哈希?

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

我想承诺有所作为, 在分支 A 更改 File1 上提交 xxxxx 在分支 B 上提交 yyyyy 更改 File2

enter image description here

2 个答案:

答案 0 :(得分:1)

我不确定,但我认为您已经提到的 git log 可以帮助您。

有一个选项/变体,即 ...,用于显示 2 个分支之间的对称差异,有关详细信息,请参阅 the man page。显示更改文件的命令是:

git log --stat branchA...branchB

答案 1 :(得分:0)

你可以试试下面的方法

git diff branch1 branch2 -- file1

例如:git diff master feature/xyz file1.java

更多详情请参考https://stackoverflow.com/a/4099805/6309111