从一个分支被分支到当前分支之后,最好的方法是什么?目前我的解决方案是:

git log $(git merge-base HEAD branch)..branch

git-diff的文档表明git diff A…B等价于git diff $(git-merge-base A B) B。另一方面,git-rev-parse的文档表明r1…R2被定义为r1 R2 -而不是$(git merge-base -all r1 R2)。

为什么这些不同呢?注意git diff HEAD…分支给了我想要的差异,但相应的git日志命令给了我比我想要的更多。

在图片中,假设:

         x---y---z---branch
        /
---a---b---c---d---e---HEAD

我想要得到一个包含提交x y z的日志。

git diff HEAD…Branch给出这些提交 然而,git log HEAD…Branch给出x y z c d e。


当前回答

在那里抛出一个-p来查看一些FILE CHANGES

git log -p master..branch

做一些别名:

alias gbc="git branch --no-color | sed -e '/^[^\*]/d' -e 's/* \\(.*\\)/\1/'"

alias gbl='git log -p master..\`gbc\`'

查看分支的唯一提交:

gbl

其他回答

In the context of a revision list, A...B is how git-rev-parse defines it. git-log takes a revision list. git-diff does not take a list of revisions - it takes one or two revisions, and has defined the A...B syntax to mean how it's defined in the git-diff manpage. If git-diff did not explicitly define A...B, then that syntax would be invalid. Note that the git-rev-parse manpage describes A...B in the "Specifying Ranges" section, and everything in that section is only valid in situations where a revision range is valid (i.e. when a revision list is desired).

要获得只包含x, y和z的日志,请尝试git log HEAD..branch(两个点,而不是三个点)。这与git日志分支相同——而不是HEAD,这意味着所有在分支上的提交都不在HEAD上。

git log --cherry-mark --oneline from_branch...to_branch

(3个点)但有时它会显示“+”而不是“=”

查看当前分支自master分支以来的日志:

Git日志管理…

如果你当前在master上,查看不同分支的日志,因为它是从master上分支的:

Git日志

在Git 2.30(2021年第一季度)中,“Git diff A…B(man)”学会了“Git diff—merge-base A B(man)”,这是说同样事情的一个更长的简写。

因此,你可以使用git diff——merge-base <branch> HEAD来做到这一点。这应该等价于git diff <branch>…HEAD,但没有在diff中使用范围符号的混乱。

您希望看到的是传出提交的列表。你可以用

git log master..branchName 

or

git log master..branchName --oneline

在这里,我假设“branchName”是作为“master”的跟踪分支创建的。

类似地,要查看传入的更改,您可以使用:

git log branchName..master