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>
This commit is contained in:
parent
9e2163ea45
commit
46acd3fa32
@ -690,6 +690,25 @@ may be any path to a file tracked by git.
|
|||||||
Examples
|
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]]
|
[[checking-for-equal-branches]]
|
||||||
Check whether two branches point at the same history
|
Check whether two branches point at the same history
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
Loading…
Reference in New Issue
Block a user