简体   繁体   English

如何仅获取特定分支的Git日志?

[英]How do I get the Git log for a specific branch only?

Assuming the following Git history: 假设以下Git历史记录:

Branch1     B---C-------F---G
           /     \           \
Master    A-------D---E-------H

Doing a git log master gives the log entries in following order ABCDEFGH. 执行git log master按以下顺序给出日志条目ABCDEFGH。 - but I'm interested in history of master-only (ie ADEH ) - 但我对仅限大师的历史感兴趣(即ADEH

How can I "get rid" of the unwanted log-entries from Branch1 ? 如何“摆脱” Branch1中不需要的日志条目? I tried a lot of options for git log , but I cannot find anything appropriate... 我为git log尝试了很多选项,但我找不到合适的东西......


This leads to a further thing I don't understand in this context: 这导致在这种情况下我不理解的另一件事:

Looking at the log-history given by git log master it shows how my branch master evolved ( ABCDEFGH ). 查看git log master给出的日志历史,它显示了我的分支主机如何进化( ABCDEFGH )。

But doing a git checkout HEAD~1 (assuming master=HEAD) gives me E (Evolution HEAD~3 : A - HEAD~2 : D - HEAD~1 : E - HEAD : H -> ADEH ) 但做一个git checkout HEAD~1 (假设master = HEAD)给我E (Evolution HEAD~3A - HEAD~2D - HEAD~1E - HEADH - > ADEH

This is what I don't understand: the ancestor of H looking at git log is G , while the ancestor of H looking at git checkout is E . 这是我不明白的: H看着git log的祖先是G ,而看着git checkoutH的祖先是E。

I don't understand this - What's the ancestor of H : G or E ?... 我不明白这一点 - HGE的祖先是什么?......


Conclusion : What I would like to have are git log entries from HEAD to HEAD~n only (for example above n = 1...3). 结论 :我想要的是从HEADHEAD~n的 git log条目(例如,在n = 1 ... 3之上)。 How can this be achieved? 怎么能实现这一目标? Is it possible at all? 有可能吗?

What you're looking for is 你在寻找什么

git log --first-parent

Why that option is called --first-parent answers your question 为什么要调用该选项--first-parent回答你的问题

I don't understand this - What's the ancestor of H: G or E? 我不明白这一点 - H:G或E的祖先是什么?

The answer is: both . 答案是: 两者兼而有之 E is the first parent , but G is the second parent , because H is a merge commit. E是第一个父级 ,但G是第二个父级 ,因为H是合并提交。 A merge commit is one that has more than one parent. 合并提交是具有多个父级的提交。

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

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