@matheusbsbs / matheus-bagliano / commits / 46acd3fa32
Fork 0

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>

J. Bruce Fields committed May 13, 2007 at 02:14 UTC 46acd3fa32404a9373d48c9caba271c34357ec9f
1 file changed +19
Documentation/user-manual.txt
+19
@@ -690,6 +690,25 @@ may be any path to a file tracked by git.
690 Examples
691 --------
692
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 +
712 [[checking-for-equal-branches]]
713 Check whether two branches point at the same history
714 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~