OSDN Git Service

Regular updates
[twpd/master.git] / git-log-format.md
1 ---
2 title: Git log format string
3 category: Git
4 layout: 2017/sheet
5 updated: 2017-10-18
6 weight: -1
7 keywords:
8   - "git log --pretty=format:%H"
9   - "%H - Commit hash"
10   - "%an - Author"
11   - "%aD - Author date"
12 ---
13
14 ## Log format
15 {: .-three-column}
16
17 ### Pretty format
18 {: .-prime}
19
20 ```bash
21 git log --pretty="format:%H"
22 ```
23
24 See the next tables on format variables.
25
26 ### Hash
27
28 #### Commit
29
30 | Variable | Description |
31 | --- | --- |
32 | `%H` | commit hash |
33 | `%h` | (abbrev) commit hash |
34
35 #### Tree
36
37 | Variable | Description |
38 | --- | --- |
39 | `%T` | tree hash |
40 | `%t` | (abbrev) tree hash |
41
42 #### Parent
43
44 | Variable | Description |
45 | --- | --- |
46 | `%P` | parent hash |
47 | `%p` | (abbrev) parent hash |
48
49 ### Commit
50
51 | Variable | Description |
52 | --- | --- |
53 | `%s` | commit subject |
54 | `%f` | commit subject, filename style |
55 | `%b` | commit body |
56 | --- | --- |
57 | `%d` | ref names |
58 | `%e` | encoding |
59
60 ## Author and committer
61
62 ### Author
63
64 #### Name
65
66 | Variable | Description |
67 | --- | --- |
68 | `%an` | author |
69 | `%aN` | author, respecting mailmap |
70
71 #### Email
72
73 | Variable | Description |
74 | --- | --- |
75 | `%ae` | author email |
76 | `%aE` | author email, respecting mailmap |
77
78 #### Date
79
80 | Variable | Description |
81 | --- | --- |
82 | `%aD` | author date (rfc2882) |
83 | `%ar` | author date (relative) |
84 | `%at` | author date (unix timestamp) |
85 | `%ai` | author date (iso8601) |
86
87 ### Committer
88
89 #### Name
90
91 | Variable | Description |
92 | --- | --- |
93 | `%cn` | committer name |
94 | `%cN` | committer name, respecting mailmap |
95
96 #### Email
97
98 | Variable | Description |
99 | --- | --- |
100 | `%ce` | committer email |
101 | `%cE` | committer email, respecting mailmap |
102
103 #### Date
104
105 | Variable | Description |
106 | --- | --- |
107 | `%cD` | committer date (rfc2882) |
108 | `%cr` | committer date (relative) |
109 | `%ct` | committer date (unix timestamp) |
110 | `%ci` | committer date (iso8601) |
111
112 ## Also see
113
114 - [Git log cheatsheet](./git-log)