Skip to content

Commit 46acd3f

Browse files
author
J. Bruce Fields
committed
user-manual: add a "counting commits" example
This is partly just an excuse to mention --pretty= and rev-list. Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu>
1 parent 9e2163e commit 46acd3f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Documentation/user-manual.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,25 @@ may be any path to a file tracked by git.
690690
Examples
691691
--------
692692

693+
[[counting-commits-on-a-branch]]
694+
Counting the number of commits on a branch
695+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
696+
697+
Suppose you want to know how many commits you've made on "mybranch"
698+
since it diverged from "origin":
699+
700+
-------------------------------------------------
701+
$ git log --pretty=oneline origin..mybranch | wc -l
702+
-------------------------------------------------
703+
704+
Alternatively, you may often see this sort of thing done with the
705+
lower-level command gitlink:git-rev-list[1], which just lists the SHA1's
706+
of all the given commits:
707+
708+
-------------------------------------------------
709+
$ git rev-list origin..mybranch | wc -l
710+
-------------------------------------------------
711+
693712
[[checking-for-equal-branches]]
694713
Check whether two branches point at the same history
695714
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)