git rev-list 和 git rev-parse

git-rev-list - Lists commit objects in reverse chronological order

https://git-scm.com/docs/git-rev-list

按照时间顺序倒序排列的commit

 

Update: If all you need is a commit count, and you're running a newer version of git, you can use the following command:

git rev-list HEAD --count

https://github.com/chucklu/LeetCode

有master和temp两个分支,他们的共同父结点为

SHA-1: 67d9d91064128452ae40183b39aa29a0ed67a7de

获取temp上的结点,以下结点按照时间倒序

$ git rev-list master..temp 
f70bf4500daca0f0e1f75fc37a8a672ac730dc98
a4599512bcb46c2f28849a591becd321ee41fcec
2eec4dac0d46b74e130a5c4a3d5fc6f4882823af
9c1580715a078217b1eab6dd8a9dba0f05f387cc

 

获取master上的结点

$ git rev-list temp..master
31cd5ef6f068c46222fe185870c09c959dd7113e
6925ba40d15b07b66ed44700a62492576447992f
b43d2be8e481841bdc5a6f499fc202b18853b0a0
61297782d9fb28beac0c4bb7aa9b8cacf9db9c63
09f1b97c7474907ebba0c61cc605ecf22cebe27a
ec5dd1be93b5afb21b185310e52630a4f91544d0
aff4fd835d128dd33dc8188f82537d4aa1512895

 

获取共同父结点之外的结点 也是按照时间倒序,会是乱序的

$ git rev-list temp...master
31cd5ef6f068c46222fe185870c09c959dd7113e
6925ba40d15b07b66ed44700a62492576447992f
b43d2be8e481841bdc5a6f499fc202b18853b0a0
f70bf4500daca0f0e1f75fc37a8a672ac730dc98
a4599512bcb46c2f28849a591becd321ee41fcec
2eec4dac0d46b74e130a5c4a3d5fc6f4882823af
9c1580715a078217b1eab6dd8a9dba0f05f387cc
61297782d9fb28beac0c4bb7aa9b8cacf9db9c63
09f1b97c7474907ebba0c61cc605ecf22cebe27a
ec5dd1be93b5afb21b185310e52630a4f91544d0
aff4fd835d128dd33dc8188f82537d4aa1512895

 

git rev-parse

https://git-scm.com/docs/git-rev-parse

Dotted Range Notations

The .. (two-dot) Range Notation

The ^r1 r2 set operation appears so often that there is a shorthand for it. When you have two commits r1 and r2 (named according to the syntax explained in SPECIFYING REVISIONS above), you can ask for commits that are reachable from r2 excluding those that are reachable from r1 by ^r1 r2 and it can be written as r1..r2.

The …​ (three-dot) Symmetric Difference Notation

A similar notation r1...r2 is called symmetric difference of r1 and r2 and is defined as r1 r2 --not $(git merge-base --all r1 r2). It is the set of commits that are reachable from either one of r1 (left side) or r2 (right side) but not from both.

In these two shorthand notations, you can omit one end and let it default to HEAD. For example, origin.. is a shorthand for origin..HEAD and asks "What did I do since I forked from the origin branch?" Similarly, ..origin is a shorthand for HEAD..origin and asks "What did the origin do since I forked from them?" Note that .. would mean HEAD..HEAD which is an empty range that is both reachable and unreachable from HEAD.

 

 

 

posted @ 2015-09-27 12:08  ChuckLu  阅读(2897)  评论(0编辑  收藏  举报