Junio C Hamano | 28c33de | 2020-07-30 21:22:26 | [diff] [blame] | 1 | List commits that are reachable by following the `parent` links from the |
| 2 | given commit(s), but exclude commits that are reachable from the one(s) |
| 3 | given with a '{caret}' in front of them. The output is given in reverse |
| 4 | chronological order by default. |
| 5 | |
| 6 | You can think of this as a set operation. Commits reachable from any of |
| 7 | the commits given on the command line form a set, and then commits reachable |
| 8 | from any of the ones given with '{caret}' in front are subtracted from that |
| 9 | set. The remaining commits are what comes out in the command's output. |
| 10 | Various other options and paths parameters can be used to further limit the |
| 11 | result. |
| 12 | |
| 13 | Thus, the following command: |
| 14 | |
| 15 | ifdef::git-rev-list[] |
| 16 | ----------------------------------------------------------------------- |
| 17 | $ git rev-list foo bar ^baz |
| 18 | ----------------------------------------------------------------------- |
| 19 | endif::git-rev-list[] |
| 20 | ifdef::git-log[] |
| 21 | ----------------------------------------------------------------------- |
| 22 | $ git log foo bar ^baz |
| 23 | ----------------------------------------------------------------------- |
| 24 | endif::git-log[] |
| 25 | |
| 26 | means "list all the commits which are reachable from 'foo' or 'bar', but |
| 27 | not from 'baz'". |
| 28 | |
| 29 | A special notation "'<commit1>'..'<commit2>'" can be used as a |
| 30 | short-hand for "^'<commit1>' '<commit2>'". For example, either of |
| 31 | the following may be used interchangeably: |
| 32 | |
| 33 | ifdef::git-rev-list[] |
| 34 | ----------------------------------------------------------------------- |
| 35 | $ git rev-list origin..HEAD |
| 36 | $ git rev-list HEAD ^origin |
| 37 | ----------------------------------------------------------------------- |
| 38 | endif::git-rev-list[] |
| 39 | ifdef::git-log[] |
| 40 | ----------------------------------------------------------------------- |
| 41 | $ git log origin..HEAD |
| 42 | $ git log HEAD ^origin |
| 43 | ----------------------------------------------------------------------- |
| 44 | endif::git-log[] |
| 45 | |
| 46 | Another special notation is "'<commit1>'...'<commit2>'" which is useful |
| 47 | for merges. The resulting set of commits is the symmetric difference |
| 48 | between the two operands. The following two commands are equivalent: |
| 49 | |
| 50 | ifdef::git-rev-list[] |
| 51 | ----------------------------------------------------------------------- |
| 52 | $ git rev-list A B --not $(git merge-base --all A B) |
| 53 | $ git rev-list A...B |
| 54 | ----------------------------------------------------------------------- |
| 55 | endif::git-rev-list[] |
| 56 | ifdef::git-log[] |
| 57 | ----------------------------------------------------------------------- |
| 58 | $ git log A B --not $(git merge-base --all A B) |
| 59 | $ git log A...B |
| 60 | ----------------------------------------------------------------------- |
| 61 | endif::git-log[] |