@@ -5,64 +5,75 @@ layout: 2017/sheet
5
5
updated : 2017-10-11
6
6
description : " "
7
7
intro : |
8
- A list of revision specifications you can use with `git log` and many other Git commands. Summarized from `man gitrevisions` .
8
+ A list of revision specifications you can use with `git log` and many other Git commands. Summarized from `gitrevisions(7)` man page .
9
9
---
10
10
11
11
### Example usages
12
12
13
- ``` bash
14
- git log master...develop # inspect differences in branches
15
- git rebase -i HEAD~3 # rebase last 3 commits
16
- git reset --hard HEAD@{2} # undo last operation that changed HEAD
17
- git show " :/fix bug" # search commit with regex
18
- git checkout v2^{} # checkout the `v2` tag (not `v2` branch)
19
- ```
20
- The 3rd argument in each of these commands is a ` gitrevision ` .
13
+ | _ ` git log ` _ ` master...develop ` | inspect differences in branches |
14
+ | _ ` git rebase -i ` _ ` HEAD~3 ` | rebase last 3 commits |
15
+ | _ ` git reset --hard ` _ ` HEAD@{2} ` | undo last operation that changed HEAD |
16
+ | _ ` git checkout ` _ ` v2^{} ` | checkout the ` v2 ` tag (not ` v2 ` branch) |
17
+ {: .-mute-em}
18
+
19
+ The 3rd argument in each of these commands is a ` gitrevision ` . These gitrevisions can be passed to many Git commands.
21
20
22
21
### Common git revisions
23
22
24
- | Reference | Description |
25
- | --- | --- |
26
- | ` dae68e1 ` | sha1 |
27
- | ` HEAD ` | reference |
28
- | ` v1.0.0 ` | tag |
29
- | --- | --- |
30
- | ` master ` | local branch |
31
- | ` origin/master ` | remote branch |
32
- | --- | --- |
33
- | ` master~2 ` | 2 commits back from master |
34
- | --- | --- |
35
- | ` master..fix ` | reachable from * fix* but not * master* |
36
- | ` master...fix ` | reachable from * fix* and * master* , but not both |
37
-
38
- These are just the common ones, there's a lot more below!
23
+ | Reference | Description |
24
+ | --- | --- |
25
+ | _ ` git show ` _ ` dae68e1 ` | sha1 |
26
+ | _ ` git show ` _ ` HEAD ` | reference |
27
+ | _ ` git show ` _ ` v1.0.0 ` | tag |
28
+ | --- | --- |
29
+ | _ ` git show ` _ ` master ` | local branch |
30
+ | _ ` git show ` _ ` origin/master ` | remote branch |
31
+ | --- | --- |
32
+ | _ ` git show ` _ ` master~2 ` | 2 commits back from master |
33
+ | --- | --- |
34
+ | _ ` git show ` _ ` master..fix ` | reachable from * fix* but not * master* |
35
+ | _ ` git show ` _ ` master...fix ` | reachable from * fix* and * master* , but not both |
36
+ {: .-mute-em}
37
+
38
+ These are just the common ones, there's a lot more below! (These work in many other commands, not just ` git show ` .)
39
39
40
40
## Reference
41
41
42
42
### Commits
43
43
44
- | ` dae68e1 ` | sha1 |
44
+ | _ ` git checkout ` _ ` dae68e1 ` | sha1 |
45
+ {: .-mute-em}
45
46
46
47
### References
47
48
48
- | ` HEAD ` | reference |
49
- | ` master ` | branch |
50
- | ` v1.0.0 ` | tag |
51
- | ` origin/master ` | aka, * refs/remotes/origin/master* |
52
- | ` heads/master ` | aka, * refs/heads/master* |
49
+ | Example | Description |
50
+ | --- | --- |
51
+ | _ ` git checkout ` _ ` HEAD ` | reference |
52
+ | _ ` git checkout ` _ ` master ` | branch |
53
+ | _ ` git checkout ` _ ` v1.0.0 ` | tag |
54
+ | --- | --- |
55
+ | _ ` git checkout ` _ ` origin/master ` | aka, * refs/remotes/origin/master* |
56
+ | _ ` git checkout ` _ ` heads/master ` | aka, * refs/heads/master* |
57
+ {: .-mute-em}
53
58
54
59
### Searching back
55
60
56
- | ` master@{yesterday} ` | also * 1 day ago* , etc |
57
- | ` master@{2} ` | 2nd prior value |
58
- | ` master@{push} ` | where * master* would push to |
59
- | ` master^ ` | parent commit |
60
- | ` master^2 ` | 2nd parent, eg, what it merged |
61
- | ` master~5 ` | 5 parents back |
62
- | ` master^0 ` | this commit; disambiguates from tags |
63
- | ` v0.99.8^{tag} ` | can be * commit* , * tag* , * tree* , * object* |
64
- | ` v0.99.8^{} ` | defaults to * {tag}* |
65
- | ` :/fix bug ` | searches commit messages |
61
+ | Example | Description |
62
+ | --- | --- |
63
+ | _ ` git checkout ` _ ` master@{yesterday} ` | also * 1 day ago* , etc |
64
+ | _ ` git checkout ` _ ` master@{2} ` | 2nd prior value |
65
+ | _ ` git checkout ` _ ` master@{push} ` | where * master* would push to |
66
+ | --- | --- |
67
+ | _ ` git checkout ` _ ` master^ ` | parent commit |
68
+ | _ ` git checkout ` _ ` master^2 ` | 2nd parent, eg, what it merged |
69
+ | _ ` git checkout ` _ ` master~5 ` | 5 parents back |
70
+ | _ ` git checkout ` _ ` master^0 ` | this commit; disambiguates from tags |
71
+ | --- | --- |
72
+ | _ ` git checkout ` _ ` v0.99.8^{tag} ` | can be * commit* , * tag* , * tree* , * object* |
73
+ | _ ` git checkout ` _ ` v0.99.8^{} ` | defaults to * {tag}* |
74
+ | --- | --- |
75
+ | _ ` git checkout ` _ ` ":/fix bug" ` | searches commit messages |
76
+ {: .-mute-em}
66
77
67
78
### Other
68
79
@@ -73,13 +84,14 @@ These are just the common ones, there's a lot more below!
73
84
74
85
### Ranges
75
86
76
- | ` master ` | reachable parents from master |
77
- | ` ^master ` | exclude reachable parents from master |
78
- | ` master..fix ` | reachable from * fix* but not * master* |
79
- | ` master...fix ` | reachable from * fix* and * master* , but not both |
80
- | ` HEAD^@ ` | parents of * HEAD* |
81
- | ` HEAD^! ` | * HEAD* , then excluding parents's ancestors |
82
- | ` HEAD^{:/fix} ` | search previous * HEAD* s matching criteria |
87
+ | _ ` git log ` _ ` master ` | reachable parents from master |
88
+ | _ ` git log ` _ ` ^master ` | exclude reachable parents from master |
89
+ | _ ` git log ` _ ` master..fix ` | reachable from * fix* but not * master* |
90
+ | _ ` git log ` _ ` master...fix ` | reachable from * fix* and * master* , but not both |
91
+ | _ ` git log ` _ ` HEAD^@ ` | parents of * HEAD* |
92
+ | _ ` git log ` _ ` HEAD^! ` | * HEAD* , then excluding parents's ancestors |
93
+ | _ ` git log ` _ ` HEAD^{:/fix} ` | search previous * HEAD* s matching criteria |
94
+ {: .-mute-em}
83
95
84
96
### Ranges illustration
85
97
@@ -90,5 +102,11 @@ A ─┬─ E ── F ── G master
90
102
```
91
103
{: .-box-chars.-setup}
92
104
93
- | ` master..fix ` | BCD |
94
- | ` master...fix ` | BCD and EFG |
105
+ | _ ` git log ` _ ` master..fix ` | BCD |
106
+ | _ ` git log ` _ ` master...fix ` | BCD and EFG |
107
+ {: .-mute-em}
108
+
109
+ ## References
110
+
111
+ * [ Git Tools - Revision Selection] ( https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html ) _ (git-scm.com)_
112
+ * [ gitrevisions(7)] ( https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html ) _ (kernel.org)_
0 commit comments