Skip to content

Commit aa4eb50

Browse files
committed
git-revisions: update
1 parent 5b6956a commit aa4eb50

1 file changed

Lines changed: 66 additions & 41 deletions

File tree

‎git-revisions.md‎

Lines changed: 66 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,94 @@
11
---
22
title: Git revisions
33
category: Git
4+
layout: 2017/sheet
5+
updated: 2017-10-11
6+
description: ""
7+
intro: |
8+
A list of revision specifications you can use with `git log` and many other Git commands. Summarized from `man gitrevisions`.
49
---
510

11+
### Example usages
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`.
21+
22+
### Common git revisions
23+
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!
39+
40+
## Reference
41+
642
### Commits
743

844
| `dae68e1` | sha1 |
9-
{:.shortcuts}
1045

1146
### References
1247

13-
| `HEAD` | reference |
14-
| `master` | branch |
15-
| `v1.0.0` | tag |
48+
| `HEAD` | reference |
49+
| `master` | branch |
50+
| `v1.0.0` | tag |
1651
| `origin/master` | aka, *refs/remotes/origin/master* |
17-
| `heads/master` | aka, *refs/heads/master* |
18-
{:.shortcuts}
52+
| `heads/master` | aka, *refs/heads/master* |
1953

2054
### Searching back
2155

22-
| `master@{yesterday}` | also *1 day ago*, etc |
23-
| `master@{2}` | 2nd prior value |
24-
| `master@{push}` | where *master* would push to |
25-
| `master^` | parent commit |
26-
| `master^2` | 2nd parent, eg, what it merged |
27-
| `master~5` | 5 parents back |
28-
| `master^0` | this commit; disambiguates from tags |
29-
| `v0.99.8^{tag}` | can be *commit*, *tag*, *tree*, *object* |
30-
| `v0.99.8^{}` | defaults to *{tag}* |
31-
| `:/fix bug` | searches commit messages |
32-
{:.shortcuts}
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 |
3366

3467
### Other
3568

36-
| `HEAD:README` | ... |
37-
| `0:README` | (0 to 3) ... |
38-
{:.shortcuts}
69+
| `HEAD:README` | ... |
70+
| `0:README` | (0 to 3) ... |
3971

4072
## Ranges
4173

42-
| `master` | reachable parents from master |
43-
| `^master` | exclude reachable parents from master |
44-
| `master..fix` | reachable from *fix* but not *master* |
74+
### Ranges
75+
76+
| `master` | reachable parents from master |
77+
| `^master` | exclude reachable parents from master |
78+
| `master..fix` | reachable from *fix* but not *master* |
4579
| `master...fix` | reachable from *fix* and *master*, but not both |
46-
| `HEAD^@` | parents of *HEAD* |
47-
| `HEAD^!` | *HEAD*, then excluding parents's ancestors |
48-
| `HEAD^{:/fix}` | search previous *HEAD*s matching criteria |
49-
{:.shortcuts}
80+
| `HEAD^@` | parents of *HEAD* |
81+
| `HEAD^!` | *HEAD*, then excluding parents's ancestors |
82+
| `HEAD^{:/fix}` | search previous *HEAD*s matching criteria |
5083

5184
### Ranges illustration
5285

5386
```nohighlight
54-
A -+- E - F - G master
55-
'- B - C - D fix
56-
57-
master..fix = BCD
58-
master...fix = BCD and EFG
87+
A ─┬─ E ── F ── G master
88+
│
89+
└─ B ── C ── D fix
5990
```
91+
{: .-box-chars.-setup}
6092

61-
## Example usages
62-
63-
```sh
64-
git log master...develop # inspect differences in branches
65-
git rebase -i HEAD~3 # rebase last 3 commits
66-
git reset --hard HEAD@{2} # undo last operation that changed HEAD
67-
git show ":/fix bug" # search commit with regex
68-
git checkout v2^{} # checkout the `v2` tag (not `v2` branch)
69-
```
93+
| `master..fix` | BCD |
94+
| `master...fix` | BCD and EFG |

0 commit comments

Comments
 (0)