@@ -14,22 +14,215 @@ can also make more specific requests:
14
14
$ git log fs/ # commits that modify any file under fs/
15
15
$ git log -S'foo()' # commits that add or remove any file data
16
16
# matching the string 'foo()'
17
+ $ git log --no-merges # dont show merge commits
17
18
18
19
And of course you can combine all of these; the following finds
19
20
commits since v2.5 which touch the Makefile or any file under fs:
20
21
21
22
$ git log v2.5.. Makefile fs/
22
23
24
+ Git log will show a listing of each commit, with the most recent commits
25
+ first, that match the arguments given to the log command.
26
+
27
+ commit f491239170cb1463c7c3cd970862d6de636ba787
28
+ Author: Matt McCutchen <matt@mattmccutchen.net>
29
+ Date: Thu Aug 14 13:37:41 2008 -0400
30
+
31
+ git format-patch documentation: clarify what --cover-letter does
32
+
33
+ commit 7950659dc9ef7f2b50b18010622299c508bfdfc3
34
+ Author: Eric Raible <raible@gmail.com>
35
+ Date: Thu Aug 14 10:12:54 2008 -0700
36
+
37
+ bash completion: 'git apply' should use 'fix' not 'strip'
38
+ Bring completion up to date with the man page.
39
+
23
40
You can also ask git log to show patches:
24
41
25
42
$ git log -p
26
43
27
- See the "--pretty" option in the linkgit: git-log [ 1] man page for more
28
- display options.
44
+ commit da9973c6f9600d90e64aac647f3ed22dfd692f70
45
+ Author: Robert Schiele <rschiele@gmail.com>
46
+ Date: Mon Aug 18 16:17:04 2008 +0200
47
+
48
+ adapt git-cvsserver manpage to dash-free syntax
49
+
50
+ diff --git a/Documentation/git-cvsserver.txt b/Documentation/git-cvsserver.txt
51
+ index c2d3c90..785779e 100644
52
+ --- a/Documentation/git-cvsserver.txt
53
+ +++ b/Documentation/git-cvsserver.txt
54
+ @@ -11,7 +11,7 @@ SYNOPSIS
55
+ SSH:
56
+
57
+ [verse]
58
+ -export CVS_SERVER=git-cvsserver
59
+ +export CVS_SERVER="git cvsserver"
60
+ 'cvs' -d :ext:user@server/path/repo.git co <HEAD_name>
61
+
62
+ pserver (/etc/inetd.conf):
63
+
64
+ ### Log Stats ###
65
+
66
+ If you pass the <code >--stat</code > option to 'git log', it will show you
67
+ which files have changed in that commit and how many lines were added and
68
+ removed from each.
69
+
70
+ $ git log --stat
71
+
72
+ commit dba9194a49452b5f093b96872e19c91b50e526aa
73
+ Author: Junio C Hamano <gitster@pobox.com>
74
+ Date: Sun Aug 17 15:44:11 2008 -0700
75
+
76
+ Start 1.6.0.X maintenance series
77
+
78
+ Documentation/RelNotes-1.6.0.1.txt | 15 +++++++++++++++
79
+ RelNotes | 2 +-
80
+ 2 files changed, 16 insertions(+), 1 deletions(-)
81
+
82
+
83
+ ### Formatting the Log ###
84
+
85
+ You can also format the log output almost however you want. The '--pretty'
86
+ option can take a number of preset formats, such as 'oneline':
87
+
88
+ $ git log --pretty=oneline
89
+ a6b444f570558a5f31ab508dc2a24dc34773825f dammit, this is the second time this has reverted
90
+ 49d77f72783e4e9f12d1bbcacc45e7a15c800240 modified index to create refs/heads if it is not
91
+ 9764edd90cf9a423c9698a2f1e814f16f0111238 Add diff-lcs dependency
92
+ e1ba1e3ca83d53a2f16b39c453fad33380f8d1cc Add dependency for Open4
93
+ 0f87b4d9020fff756c18323106b3fd4e2f422135 merged recent changes: * accepts relative alt pat
94
+ f0ce7d5979dfb0f415799d086e14a8d2f9653300 updated the Manifest file
95
+
96
+ or you can do 'short' format:
97
+
98
+ $ git log --pretty=short
99
+ commit a6b444f570558a5f31ab508dc2a24dc34773825f
100
+ Author: Scott Chacon <schacon@gmail.com>
101
+
102
+ dammit, this is the second time this has reverted
103
+
104
+ commit 49d77f72783e4e9f12d1bbcacc45e7a15c800240
105
+ Author: Scott Chacon <schacon@gmail.com>
29
106
107
+ modified index to create refs/heads if it is not there
108
+
109
+ commit 9764edd90cf9a423c9698a2f1e814f16f0111238
110
+ Author: Hans Engel <engel@engel.uk.to>
111
+
112
+ Add diff-lcs dependency
113
+
114
+ You can also use 'medium', 'full', 'fuller', 'email' or 'raw'. If those formats
115
+ aren't exactly what you need, you can also create your own format with the
116
+ '--pretty=format' option (see the linkgit: git-log [ 1] docs for all the formatting options).
117
+
118
+ $ git log --pretty=format:'%h was %an, %ar, message: %s'
119
+ a6b444f was Scott Chacon, 5 days ago, message: dammit, this is the second time this has re
120
+ 49d77f7 was Scott Chacon, 8 days ago, message: modified index to create refs/heads if it i
121
+ 9764edd was Hans Engel, 11 days ago, message: Add diff-lcs dependency
122
+ e1ba1e3 was Hans Engel, 11 days ago, message: Add dependency for Open4
123
+ 0f87b4d was Scott Chacon, 12 days ago, message: merged recent changes:
124
+
125
+ Another interesting thing you can do is visualize the commit graph with the
126
+ '--graph' option, like so:
127
+
128
+ $ git log --pretty=format:'%h : %s' --graph
129
+ * 2d3acf9 : ignore errors from SIGCHLD on trap
130
+ * 5e3ee11 : Merge branch 'master' of git://github.com/dustin/grit
131
+ |\
132
+ | * 420eac9 : Added a method for getting the current branch.
133
+ * | 30e367c : timeout code and tests
134
+ * | 5a09431 : add timeout protection to grit
135
+ * | e1193f8 : support for heads with slashes in them
136
+ |/
137
+ * d6016bc : require time for xmlschema
138
+
139
+ It will give a pretty nice ASCII representation of the commit history lines.
140
+
141
+
142
+ ### Ordering the Log ###
143
+
144
+ You can also view the log entries in a few different orders.
30
145
Note that git log starts with the most recent commit and works
31
146
backwards through the parents; however, since git history can contain
32
147
multiple independent lines of development, the particular order that
33
148
commits are listed in may be somewhat arbitrary.
34
149
150
+ If you want to specify a certain order, you can add an ordering option
151
+ to the git log command.
152
+
153
+ By default, the commits are shown in reverse chronological order.
154
+
155
+ However, you can also specify '--topo-order', which makes the commits
156
+ appear in topological order (i.e. descendant commits are shown before their parents).
157
+ If we view the git log for the Grit repo in topo-order, you can see that the
158
+ development lines are all grouped together.
159
+
160
+ $ git log --pretty=format:'%h : %s' --topo-order --graph
161
+ * 4a904d7 : Merge branch 'idx2'
162
+ |\
163
+ | * dfeffce : merged in bryces changes and fixed some testing issues
164
+ | |\
165
+ | | * 23f4ecf : Clarify how to get a full count out of Repo#commits
166
+ | | * 9d6d250 : Appropriate time-zone test fix from halorgium
167
+ | | |\
168
+ | | | * cec36f7 : Fix the to_hash test to run in US/Pacific time
169
+ | | * | decfe7b : fixed manifest and grit.rb to make correct gemspec
170
+ | | * | cd27d57 : added lib/grit/commit_stats.rb to the big list o' files
171
+ | | * | 823a9d9 : cleared out errors by adding in Grit::Git#run method
172
+ | | * | 4eb3bf0 : resolved merge conflicts, hopefully amicably
173
+ | | |\ \
174
+ | | | * | d065e76 : empty commit to push project to runcoderun
175
+ | | | * | 3fa3284 : whitespace
176
+ | | | * | d01cffd : whitespace
177
+ | | | * | 7c74272 : oops, update version here too
178
+ | | | * | 13f8cc3 : push 0.8.3
179
+ | | | * | 06bae5a : capture stderr and log it if debug is true when running commands
180
+ | | | * | 0b5bedf : update history
181
+ | | | * | d40e1f0 : some docs
182
+ | | | * | ef8a23c : update gemspec to include the newly added files to manifest
183
+ | | | * | 15dd347 : add missing files to manifest; add grit test
184
+ | | | * | 3dabb6a : allow sending debug messages to a user defined logger if provided; tes
185
+ | | | * | eac1c37 : pull out the date in this assertion and compare as xmlschemaw, to avoi
186
+ | | | * | 0a7d387 : Removed debug print.
187
+ | | | * | 4d6b69c : Fixed to close opened file description.
188
+
189
+ You can also use '--date-order', which orders the commits primarily by commit date.
190
+ This option is similar to --topo-order in the sense that no parent comes before all of its children,
191
+ but otherwise things are still ordered in the commit timestamp order. You can
192
+ see that development lines are not grouped together here, that they jump around
193
+ as parallel development occurred:
194
+
195
+ $ git log --pretty=format:'%h : %s' --date-order --graph
196
+ * 4a904d7 : Merge branch 'idx2'
197
+ |\
198
+ * | 81a3e0d : updated packfile code to recognize index v2
199
+ | * dfeffce : merged in bryces changes and fixed some testing issues
200
+ | |\
201
+ | * | c615d80 : fixed a log issue
202
+ |/ /
203
+ | * 23f4ecf : Clarify how to get a full count out of Repo#commits
204
+ | * 9d6d250 : Appropriate time-zone test fix from halorgium
205
+ | |\
206
+ | * | decfe7b : fixed manifest and grit.rb to make correct gemspec
207
+ | * | cd27d57 : added lib/grit/commit_stats.rb to the big list o' file
208
+ | * | 823a9d9 : cleared out errors by adding in Grit::Git#run method
209
+ | * | 4eb3bf0 : resolved merge conflicts, hopefully amicably
210
+ | |\ \
211
+ | * | | ba23640 : Fix CommitDb errors in test (was this the right fix?
212
+ | * | | 4d8873e : test_commit no longer fails if you're not in PDT
213
+ | * | | b3285ad : Use the appropriate method to find a first occurrenc
214
+ | * | | 44dda6c : more cleanly accept separate options for initializin
215
+ | * | | 839ba9f : needed to be able to ask Repo.new to work with a bar
216
+ | | * | d065e76 : empty commit to push project to runcoderun
217
+ * | | | 791ec6b : updated grit gemspec
218
+ * | | | 756a947 : including code from github updates
219
+ | | * | 3fa3284 : whitespace
220
+ | | * | d01cffd : whitespace
221
+ | * | | a0e4a3d : updated grit gemspec
222
+ | * | | 7569d0d : including code from github updates
223
+
224
+
225
+ Lastly, you can reverse the order of the log with the '--reverse' option.
226
+
227
+
35
228
[ gitcast: c4-git-log ] ("GitCast #4 : Git Log")
0 commit comments