git - 如何查看一个分支的更改是否已经在另一个分支中完成?
问题描述
我想知道我在 BranchA 上的所有代码更改是否已经在 BranchB 上应用,无论提交 ID 是否相同或 BranchB 是否有大量额外更改
那可能吗?
例子:
Branch A : Commit 111... -> Add line 23
Commit 222... -> Add line 24
Branch B: Commit 333... -> Add line 23
Commit 444... -> Add line 24
Commit 555... -> Remove line 24
Commit 666... -> Add line 25
Commit 777... -> Add line 26
What I basically would like to know is whether the two changes from Branch A are already applied by other commits on Branch B.
In this case, the output I would like to see is:
- Add line 24
Why? Because this is the only change from Branch A not matching latest state of Branch B. I want to discard extra staff exclusive in Branch B (commits 666 and 777). I also want to consider latest state of Branch B, so even Branch B added at some point line 24, the latest state is removed, so that is the only differing change in regards to Branch A
当使用比较和差异时,我通常会看到来自 B 分支的所有额外员工,我不感兴趣,因为我只想知道分支 A 的上下文中的差异
解决方案
如果您合并所有更改,则可以这样做git log BranchB..BranchA
(即“给我所有在 A 中而不在 B 中的提交”)。如果这不返回任何内容,则应用所有 A 更改。
如果您使用变基或以完全不同的方式实施更改,则无法检查这一点,因为您的更改可能在以后被更改或完全覆盖。您可以尝试 grep 一些相关行或构建软件,看看它是否具有您想要的功能,但没有通用的方法。
推荐阅读
- azure-devops - 基于性能回归的 Azure DevOps 通过/失败构建
- javascript - 重新格式化 Javascript 对象以与 Foreach 一起使用
- c# - 有没有办法在应用程序运行时更改语言
- react-select - 如何自定义下拉菜单
- javascript - 根据时间显示不同的图像
- python - 使用 Python 从 Jira 中提取所有问题时,有没有办法将最新的活动历史记录添加到问题列表中?
- angular - if() 返回的单元测试;在一个函数中
- vb.net - 在没有 Office 365 的计算机上安装 Office 365 组件
- linux - 如何为需要以特定顺序运行的 2 个或更多服务器构建启动/关闭脚本?
- ros - 在动力学上安装turtlebot