Code

user-manual: add a "counting commits" example
authorJ. Bruce Fields <bfields@citi.umich.edu>
Sun, 13 May 2007 06:14:45 +0000 (02:14 -0400)
committerJ. Bruce Fields <bfields@citi.umich.edu>
Fri, 18 May 2007 01:58:51 +0000 (21:58 -0400)
This is partly just an excuse to mention --pretty= and rev-list.

Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu>
Documentation/user-manual.txt

index 9cc5fc9db3b3c8be33b6d13e281fc85a72a9c866..242f5aa479620e087d70a1154c86cc142f9e9c43 100644 (file)
@@ -690,6 +690,25 @@ may be any path to a file tracked by git.
 Examples
 --------
 
+[[counting-commits-on-a-branch]]
+Counting the number of commits on a branch
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Suppose you want to know how many commits you've made on "mybranch"
+since it diverged from "origin":
+
+-------------------------------------------------
+$ git log --pretty=oneline origin..mybranch | wc -l
+-------------------------------------------------
+
+Alternatively, you may often see this sort of thing done with the
+lower-level command gitlink:git-rev-list[1], which just lists the SHA1's
+of all the given commits:
+
+-------------------------------------------------
+$ git rev-list origin..mybranch | wc -l
+-------------------------------------------------
+
 [[checking-for-equal-branches]]
 Check whether two branches point at the same history
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~