关于git:你的分支在X commits之前领先于’origin / master’。

Your branch is ahead of 'origin/master' by X commits. How to find the X commits?

本问题已经有最佳答案,请猛点这里访问。

我正在使用以下命令检查X提交:

1
git log --author=<my-name> -<X>

但问题是,我意外地从另一个存储库中提取了代码,并将提交从存储库添加到了本地Git存储库中。

所以我不能使用上面的命令,因为新提交包含一些其他作者。


命令

1
git log origin/master..master

显示在master上但不在origin/master上的提交。


我为这个命令创建了一个别名,列出了尚未推送的提交。

git log --branches --not --remotes --decorate --oneline

< /块引用>

这是在查看未执行的git提交时发布的命令cxreg的变体。

还有很多其他有用的方法来解析该日志中的提交树。


treeish..treeish符号的作用是准确地看到第二个引用中存在的提交,而不是第一个引用中存在的提交。从Git日志帮助:

A regular D..M computes the set of commits that are ancestors of M, but excludes the ones that are ancestors of D. This is useful to see what happened to the history leading to M since D, in the sense that"what does M have that did not exist in D".

使用git loggit show时,您可以输出一个列表,其中包含D..M差异中每个提交压力的一行:

1
git show -s --oneline branch..HEAD

1
git log --oneline branch..HEAD

将其与字数配对,您就可以准确地输出要查找的提交数:

1
git log --oneline branch..HEAD | wc -l


此问题已在另一个帖子中得到解答:

1
git log origin/master..HEAD

(请参阅查看未处理的git提交)


我用这个:

1
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative

它以图形的形式显示提交,其中包含所有分支及其名称。

我的建议是在~/.gitconfig中为它创建别名