Is it possible to get the number of commits in last pull ?

Viewed 277

Assume that i am pulling changes from the repo to update my local repository. The changes which I pulled includes 4 commits. Is there any way to get the number of commits in the recent "git pull" ? Thanks!

1 Answers

Git stores previous states for references, you can query them with <refname>@{<n>} syntax. Pull operation performs merging thus updating HEAD and branch references. You can find state of HEAD prior to update with HEAD@{1} (or branch_name@{1} for branch reference) and then find range of pulled commits with HEAD@{1}..HEAD. Then you can do with this commits whatever you want:

  • count them: git rev-list HEAD@{1}..HEAD@{0} --count
  • list log: git log HEAD@{1}..HEAD@{0}

Specific reference ORIG_HEAD can be used instead of HEAD@{1}, but <refname>@{<n>} is more general and more powerful tool to study.

Related