如何获取通过 git pull 添加到本地存储库的新提交的数量?
当我运行 git pull 时,我想知道有多少提交添加到我的本地存储库,最好仅在当前分支上。有没有办法获取这些信息?
git-pull 的手册似乎没有说明任何相关内容,而且我还没有在网上找到任何专门处理此问题的线程。
When I run git pull
, I'd like to know how many commits the pull
added to my local repository, preferably on the current branch only. Is there a way to get this information ?
The manual for git-pull
doesn't seem to indicate anything about this, and I haven't found any thread online specifically dealing with this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Git pull 不会给你这些信息。
但你可以做的是:
git fetch
git status
这将为您提供有关将拉取多少提交的信息。
Git pull doesn't give you that information.
But what you can do is:
git fetch
git status
And this will give you information about how many commits will be pulled.
继续@Grzegorz的答案,但完全替代了 git pull ,并且对我的问题有更合适的答案(仅请求新提交的数量),这是我想出的命令
:输出类似这样的内容:
在括号
[behind 6]
之间的文本中给出新提交的数量,这意味着 6 个新提交已从远程拉取到当前分支。PS:当然,如果默认情况下使用
git pull --rebase
,则必须将git merge
更改为git rebase
。Continuing on @Grzegorz' answer, but with a complete substitute for
git pull
and more appropriate answer to my question (requesting only the number of new commits), here is the command I came up with:Which will output something like this:
giving you the number of new commits in the text between brackets
[behind 6]
meaning 6 new commits have been pulled to the current branch from the remote.PS: Of course, if you
git pull --rebase
by default, you would have to changegit merge
withgit rebase
.