version control - Number of commits on branch in git -
i'm writing small script , want know how many commits made on current branch since created.
in example i'd have 2 commits made on child
:
git checkout master git checkout -b child ... git commit -a ... git commit -a
so want is
commit_number = ... echo $commit_number
thank help.
git can provide number of commits without further shell scripting.
git rev-list master.. --count
rev-list
semi-hidden (not listed in git help
) command used work revisions.
as master..
list commits base of master , current branch current branch, --count
give count of them.
if instead want have number of commits between 2 revisions use master...
. elaborate: between in master recent common ancestor of master , current branch (head), , current branch again. if visualize commit history tree should able follow 2 branches common ancestor. master..
on other hand count 1 of 2 branches.
so whether want use master..
or master...
depends on whether want know how many commits made in branch since split off (master..
), or difference between current master , branch, number of commits in master and branch since branch split off.
Comments
Post a Comment