我正在使用gitk
和git log
查看提交历史记录,并尝试查看特定提交如何到达某个分支。我可以看到历史记录中的提交,所以我知道它们在那里。
我想了解的是它们是如何合并的(它们应该保留在自己的分支上)。这是一个非常大的项目,在有问题的提交和分支的当前状态之间有数百个提交,所以我无法清楚地破译 gitk
中的有限 DAG,并且提交在其他分支中被屏蔽并合并和提交消息。
为此,我一直在尝试:
gitk {sha1hashIDstring}..branch_name
gitk {sha1hashIDstring}..branch_name --ancestry-path
git log {sha1hashIDstring}..branch_name --reverse
git log {sha1hashIDstring}..branch_name --merges --reverse
git log {sha1hashIDstring}..branch_name --ancestry-path --reverse
git log {sha1hashIDstring}..branch_name --ancestry-path --merges --reverse
而且我不明白结果。我只想查看包含相关特定提交的项目,以便我清楚地看到它是如何进入相关分支的。我该怎么做?
例
我正在寻找的,最好是gitk
但git log
就足够了:
Message Author Date #commit that merged branch z into current branch
Message Author Date #commit that merged branch y into branch z
Message Author Date #commit that merged branch x into branch y
Message Author Date #commit that merged {sha1hashIDstring} commit/branch a into branch x
Message Orig_Author Date #{sha1hashIDstring} original commit, on branch a
更多信息
我还没有看到任何答案,所以如果没有人进来,我会开始赏金,但也许我没有正确解释这个问题(我愿意接受改进和澄清的建议)。
这样做的驱动因素是我可以看到提交本身,并且我被告知它不应该在某个分支上。这是我看到的:
Message Orig_Author Date #{sha1hashIDstring} commit
Message Orig_Author Date #Merged into branch test_dec14 (includes original commit)
...
Message Author Date # unrelated commits
Message Author Date # more unrelated commits
# Stuff happened here ??? everything I do gives me hundreds of things here
# Not all of them related to the {sha1hashIDstring} commit
# No idea how to see only the ones that are
...
Message Author Date # final commit on test_jan15 branch
我被告知,除非它们被释放,否则test_dec14
中的提交不应该进入test_jan15
,因此 {sha1hashIDstring} 提交不应该在test_jan15
中,但它确实如此。我想知道为什么,它是如何到达那里的,以及谁把它放在那里。
对于问题的后半部分,"它是如何进入当前分支的?",看看 git-when-merged。
这是一个 Python 脚本,根据其自述文件:
查找提交何时合并到一个或多个分支中。 查找合并 将 COMMIT 引入指定分支的提交。 具体来说,在 BRANCH 的第一父历史记录中查找包含 COMMIT 作为祖先的最早提交。
这听起来像您在确定{sha1hashIDstring}
提交何时合并到分支test_jan15
时要查找的内容。
这是git bisect
的经典案例。 平分法可帮助您跟踪错误。在您的情况下,您只需查找一个 commitId(它被错误地放到错误的分支中)。
Bisect是一个非常简单但功能强大的工具。
http://git-scm.com/docs/git-bisecthttp://hashrocket.com/blog/posts/finding-failure-git-bisect
希望它能帮助你。
这没有被标记为"github" - 但如果项目在那里,Blame 或 History 的视觉风格(查看特定文件时文件头中的按钮)可以更容易地跟踪事情发生的时间。
不确定这是否真的解决了这个(非常)具体的问题 - 但它可能会帮助发现这个问题的有类似问题的其他人......