如何获得仅一个分支的提交历史记录? [英] How to get commit history for just one branch?
问题描述
master
创建了一个新分支 my_experiment
,并提交了多个 my_experiment
。如果我在 my_experiment
上执行 git log
,则看到对该分支进行的提交,还有提交在创建 my_experiments
分支之前至 master
。 我会发现查看所有提交到 my_experiments
分支的历史记录是非常有用的,直到它创建该分支 - 实际上是该分支的真实历史记录。否则,在查看日志时,我不清楚提交是否位于 my_experiments
分支中。
有没有办法用Git来做到这一点?
您可以使用range 来做到这一点。
git log master。
如果您签出了 my_experiment
分支。这将比较 master
处于 HEAD
( my_experiment
)。
Let's say I created a new branch my_experiment
from master
and made several commits to my_experiment
. If I do a git log
when on my_experiment
, I see the commits made to this branch, but also the commits made to master
before the my_experiments
branch was created.
I would find it very useful to see the history of all commits to the my_experiments
branch until it hits the creation of that branch - effectively a true history of just that branch. Otherwise it's not clear to me when looking through the log whether the commits were on the my_experiments
branch or not.
Is there a way to do this with Git?
You can use a range to do that.
git log master..
If you've checked out your my_experiment
branch. This will compare where master
is at to HEAD
(the tip of my_experiment
).
这篇关于如何获得仅一个分支的提交历史记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!