简体   繁体   English

git -- 跨分支交叉引用公共提交

[英]git -- cross reference common commits across branches

I have a git repo that has multiple unmerged branches, and need to get a handle on what is where.我有一个 git 存储库,它有多个未合并的分支,并且需要掌握在哪里。 SOME of them have had commits cherry-picked across, so if I do a list of commits using the top line of the log message, two of them would show the same text in different branches.他们中的一些人已经挑选了提交,所以如果我使用日志消息的第一行列出提交,其中两个会在不同的分支中显示相同的文本。

I have used git show-branch to show me all the commits and which branches they are in, and I can see some of them sharing the same text... but I have to first pick a commit msg, then search (or grep) for that text to see if it appears in another branch.我已经使用 git show-branch 向我显示所有提交以及它们所在的分支,我可以看到其中一些共享相同的文本......但我必须首先选择一个提交消息,然后搜索(或 grep)让该文本查看它是否出现在另一个分支中。

Is there a way to automate this cross referencing of common commits across branches?有没有办法自动化跨分支的常见提交的交叉引用? So that I can get a list of all branches that the commit "this fixes the config problem" is in?这样我就可以获得提交“这修复了配置问题”所在的所有分支的列表? Even better would be a list of cherry-picked commits and where their origin commit is, but I am not holding out hope for that.更好的做法是列出精心挑选的提交以及它们的原始提交在哪里,但我对此并不抱任何希望。 Just a list that shows that commit X appears in branches A, B, and C would be a tremendous help.仅显示提交 X 出现在分支 A、B 和 C 中的列表将是一个巨大的帮助。

git log has a set of options to detect cherry-picks: see --cherry-mark and below. git log有一组选项来检测cherry-picks:参见--cherry-mark及以下。

Sample usage:示例用法:

git log --cherry master...my/branch
git log --cherry-mark master...my/branch

# with more options:
git log --graph --oneline --cherry master...my/branch
git log --graph --oneline --boundaries --cherry-mark master...my/branch

This will compare commits based on their content , so even if the message was edited a cherry-picked commit will be detected.这将根据内容比较提交,因此即使消息被编辑,也会检测到精心挑选的提交。 A cherry-pick that led to a conflict will not be detected though (even if the messages are the same).但是不会检测到导致冲突的樱桃选择(即使消息相同)。

It will use the same algorithm as what git rebase uses to determine that a commit is already part of the target branch and shouldn't be replayed.它将使用与git rebase使用相同的算法来确定提交已经是目标分支的一部分并且不应重播。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM