You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何获取已合并到main分支的feature-A分支提交及Git相关疑问

Git提交查询问题解答

1. 查看仅属于feature-A分支的提交(提交B、I、J)

当feature-A分支合并到main分支(提交K为合并提交)后,要筛选出仅属于feature-A的提交,可执行以下命令:

git log --ancestry-path main^..feature-A

main^指向合并提交K的第一个父提交(即main分支合并前的最后一个提交H),--ancestry-path会限定只显示位于main^到feature-A之间的提交,也就是B、I、J。

2. 排除合并提交(如提交I)的方法

在上述命令基础上添加--no-merges参数,即可过滤掉所有合并提交:

git log --ancestry-path --no-merges main^..feature-A

执行后会仅显示feature-A分支上的非合并提交B和J。

3. 为什么git log main..feature-A无输出?

main..feature-A的语法含义是查询存在于feature-A分支,但不存在于main分支的提交。由于你已经将feature-A合并到main分支,main分支的历史已经包含了feature-A分支的所有提交路径,没有符合该条件的提交,因此命令无输出。

内容的提问来源于stack exchange,提问作者humblefool

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 12:42:39