如何通过git历史记录或“如何获取当前分支”来查看提交的路径? [英] How do I see a commit's path through git history, or "how it got in the current branch"?
问题描述
我正在使用 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
我不理解结果。我只想查看包含特定提交的项目,以便我清楚地看到它是如何进入有问题的分支的。我怎么做?
示例
我正在寻找 git log
就足够了:
消息作者日期#commit合并分支z到当前分支
消息作者日期#commit合并分支y到分支z
消息作者日期#commit合并分支x到分支y
消息作者日期#commit将{sha1hashIDstring}提交/分支a合并到分支x
消息Orig_Author日期#{sha1hashIDstring}原始提交,分支
更多信息
我还没有看到任何答案,所以如果没有人来但是也许我不是在正确地解释问题(我愿意提出改进和澄清的建议)。
驱动程序是这样的,我可以看到提交本身,并且我被告知它不应该在某个分支上。以下是我所看到的:
消息Orig_Author日期#{sha1hashIDstring}提交
消息Orig_Author Date #Merged into branch test_dec14(包含原始提交)
...
消息作者日期#不相关的提交
消息作者日期#更多不相关的提交
#这里发生了什么?我做的每件事都给了我数以百计的东西
#不是所有的都与{sha1hashIDstring}提交相关
#不知道如何查看只有
...
消息作者日期#test_jan15分支上的最终提交
我被告知<$ c $除非它们被释放,否则c> test_dec14 应该不是 test_jan15
,但它是。我想知道为什么,它是如何到达那里的,以及是谁把它放在那里的。
对于问题的后半部分, 它是如何得到当前分支的?,看看 GIT-时归并。
这是一个Python脚本,根据其自述:
一个提交被合并到一个或多个分支中。查找将COMMIT带入指定BRANCH(es)的合并
提交。具体来说,查找BRANCH的第一条父历史记录中包含COMMIT作为祖先的最旧提交。
这听起来像是什么您正在寻找确定何时将 {sha1hashIDstring}
提交合并到 test_jan15
分支中的情况。 p>
I'm looking in the commit history using gitk
and git log
and I'm trying to see how a specific commit arrived in a certain branch. I can see the commits in the history, so I know they are there.
What I want to understand is how they got merged (they were supposed to remain on their own branch). This is a very large project and there are hundreds of commits between the commit in question and the current state of the branch, so I cannot clearly decipher through the limited DAG in gitk
, and the commit gets masked in other branches and merges and commit messages.
To do this, I have been trying:
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
And I'm not understanding the results. I ONLY want to see items that include the specific commit in question, such that I see clearly how it got into the branch in question. How do I do so?
Example
What I'm looking for, in gitk
preferrably but git log
would suffice:
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
More Information
I'm not seeing any answers yet, so I'll start a bounty if none come in, but perhaps I'm not explaining the question right (I'm open to suggestions to improve and clarify).
The driver for this is that I can see the commit itself, and I'm being told it should not be on a certain branch. Here's what I'm seeing:
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
I'm being told commits in test_dec14
should not have made it to test_jan15
unless they were released, and as such the {sha1hashIDstring} commit SHOULD NOT BE in test_jan15
, yet it is. I want to know why, how it got there, and who put it there.
For the latter part of your question, "how it got in the current branch?", take a look at git-when-merged.
It's a Python script that will, per its readme:
Find when a commit was merged into one or more branches. Find the merge commit that brought COMMIT into the specified BRANCH(es). Specifically, look for the oldest commit on the first-parent history of BRANCH that contains the COMMIT as an ancestor.
This sounds like what you're looking for in the case of determining when the {sha1hashIDstring}
commit was merged into test_jan15
branch.
这篇关于如何通过git历史记录或“如何获取当前分支”来查看提交的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!