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.
CodePudding user response:
Git pull doesn't give you that information.
But what you can do is:
git fetch
git status
On branch master
Your branch is behind 'origin/master' by 11 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
And this will give you information about how many commits will be pulled.
CodePudding user response:
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:
git fetch ; git status -bsu no ; git merge
Which will output something like this:
## master...origin/master [behind 6]
Updating 050a8c7..b8a6c2e
Fast-forward
2.4/debian-10/Dockerfile | 2 -
2.5/debian-10/Dockerfile | 2 -
2.6/debian-10/Dockerfile | 2 -
README.md | 6 ---
4 files changed, 6 insertions( ), 6 deletions(-)
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 change git merge
with git rebase
.