我有一个从开发分支创建的发布分支。之后其他开发人员并行提交到两个分支。几天前,发布分支被合并回开发分支并关闭。
现在我们需要知道在创建发布分支和关闭它之间“开发”所做的所有提交。
请帮忙
找到 diff 的分支起点/终点的一个简单但有效的方法是“以图形方式”查看存储库树 - 并且很容易看到所有提交:
git log --graph --decorate --all --oneline
然后查看您的分支在哪里分裂并重新加入。
然后简单地对短哈希进行比较:
git diff 1a2b3c4 1a2b3c4
如果您只是想快速查看文件:
git diff 1a2b3c4 1a2b3c4 --name-only
develop
获取 SHA release
develop
之前从 release
获取 SHA 将它们插入您的存储库的 git /compare 界面:
https://github.com/<org name>/<repo name>/compare
例如:https://github.com/github/hub/compare
与填写的 SHA 进行比较的示例:https://github.com/github/hub/compare/f93e53798ff87c3ba0e99858812fc89b27e3a54b...3d3facba2c53cc62669e5166435ae350847faa88
或者,您可以运行
git log <first sha> ^<second sha>^
这应该包括两个 SHA 之间的所有提交,包括开始和结束提交本身。但您可能会发现比较更有帮助,因为它可以更优雅地处理合并提交。
hub compare
现已过时,您可以使用 gh browse-compare
代替,这是一个 gh CLI 扩展。
cli/cli
问题 4433:“添加“比较”命令”。
gh extension install kyanny/gh-browse-compare
gh alias set compare 'browse-compare'
# git clone https://github.com/django/django.git
# cd django
gh compare 3.2.8...stable/3.2.x
# => it opens https://github.com/django/django/compare/3.2.8...stable/3.2.x
# In your case
gh compare <hash-where-release-branched-off>..<hash-where-release-merged-back>
但这只会在 GitHub 上打开比较,而不会直接在终端中提供详细的提交列表。
它将打开一个带有 GitHub 比较视图的浏览器窗口,其中将列出两点之间的提交。
相反,对于提交列表:
git merge-base develop release
git log --oneline --graph --all # => identify the commit hash
# where the release branch was merged back
# into the develop branch
# or, to identify the merge back commit:
git switch develop
git log --merges --grep="Merge branch 'release'" --oneline
# Finally
git log <common-ancestor-hash>..<merge-commit-hash> --first-parent develop