Skip to content

Commit 33449ca

Browse files
committed
updated git log, removed advanced git log, added git hooks beginning, links for corruption recovery, advanced merging beginning, transfer protocols doc
1 parent 44bca92 commit 33449ca

File tree

8 files changed

+371
-13
lines changed

8 files changed

+371
-13
lines changed

text/09_Reviewing_History_Git_Log/0_ Reviewing_History_Git_Log.markdown

Lines changed: 195 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,215 @@ can also make more specific requests:
1414
$ git log fs/ # commits that modify any file under fs/
1515
$ git log -S'foo()' # commits that add or remove any file data
1616
# matching the string 'foo()'
17+
$ git log --no-merges # dont show merge commits
1718

1819
And of course you can combine all of these; the following finds
1920
commits since v2.5 which touch the Makefile or any file under fs:
2021

2122
$ git log v2.5.. Makefile fs/
2223

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+
2340
You can also ask git log to show patches:
2441

2542
$ git log -p
2643

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>
29106

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.
30145
Note that git log starts with the most recent commit and works
31146
backwards through the parents; however, since git history can contain
32147
multiple independent lines of development, the particular order that
33148
commits are listed in may be somewhat arbitrary.
34149

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+
35228
[gitcast:c4-git-log]("GitCast #4: Git Log")

text/25_Advanced_Git_Log/0_ Advanced_Git_Log.markdown

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Filtering Branches ##
2+
3+
linkgit:git-filter-branch[1]
4+
5+
can rewrite history
Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,55 @@
11
## Customizing Git ##
22

3-
(interesting or most useful git-config options)
3+
linkgit:git-config[1]
4+
5+
### Changing your Editor ###
6+
7+
$ git config --global core.editor emacs
8+
9+
### Adding Aliases ###
10+
11+
$ git config --global alias.last 'cat-file commit HEAD'
12+
13+
$ git last
14+
tree c85fbd1996b8e7e5eda1288b56042c0cdb91836b
15+
parent cdc9a0a28173b6ba4aca00eb34f5aabb39980735
16+
author Scott Chacon <schacon@gmail.com> 1220473867 -0700
17+
committer Scott Chacon <schacon@gmail.com> 1220473867 -0700
18+
19+
fixed a weird formatting problem
20+
21+
$ git cat-file commit HEAD
22+
tree c85fbd1996b8e7e5eda1288b56042c0cdb91836b
23+
parent cdc9a0a28173b6ba4aca00eb34f5aabb39980735
24+
author Scott Chacon <schacon@gmail.com> 1220473867 -0700
25+
committer Scott Chacon <schacon@gmail.com> 1220473867 -0700
26+
27+
fixed a weird formatting problem
28+
29+
### Adding Color ###
30+
31+
See all color.* options in the linkgit:git-config[1] docs
32+
33+
$ git config color.branch auto
34+
$ git config color.diff auto
35+
$ git config color.interactive auto
36+
$ git config color.status auto
37+
38+
Or, you can set all of them on with the color.ui option:
39+
40+
$ git config color.ui true
41+
42+
### Commit Template ###
43+
44+
$ git config commit.template '/etc/git-commit-template'
45+
46+
### Log Format ###
47+
48+
$ git config format.pretty oneline
49+
50+
51+
### Other Config Options ###
52+
53+
There are also a number of interesting options for packing, gc-ing, merging,
54+
remotes, branches, http transport, diffs, paging, whitespace and more. If you
55+
want to tweak these, check out the linkgit:git-config[1] docs.
Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,64 @@
11
## Git Hooks ##
22

3-
(useful or most interesting git-hooks)
3+
[Git Hooks](http://www.kernel.org/pub/software/scm/git/docs/githooks.html)
44

5-
applypatch-msg
5+
### Server Side Hooks ###
66

7-
pre-applypatch
7+
#### Post Receive ####
88

9-
http://www.kernel.org/pub/software/scm/git/docs/githooks.html
9+
10+
GIT_DIR/hooks/post-receive
11+
12+
If you wrote it in Ruby, you might get the args this way:
13+
14+
ruby
15+
rev_old, rev_new, ref = STDIN.read.split(" ")
16+
17+
Or in a bash script, something like this would work:
18+
19+
#!/bin/sh
20+
# <oldrev> <newrev> <refname>
21+
# update a blame tree
22+
while read oldrev newrev ref
23+
do
24+
echo "STARTING [$oldrev $newrev $ref]"
25+
for path in `git diff-tree -r $oldrev..$newrev | awk '{print $6}'`
26+
do
27+
echo "git update-ref refs/blametree/$ref/$path $newrev"
28+
`git update-ref refs/blametree/$ref/$path $newrev`
29+
done
30+
done
31+
32+
33+
### Client Side Hooks ###
34+
35+
36+
#### Pre Commit ####
37+
38+
Running your tests automatically before you commit
39+
40+
GIT_DIR/hooks/pre-commit
41+
42+
Here is an example of a Ruby script that runs RSpec tests before allowing a commit.
43+
44+
ruby
45+
html_path = "spec_results.html"
46+
`spec -f h:#{html_path} -f p spec` # run the spec. send progress to screen. save html results to html_path
47+
48+
# find out how many errors were found
49+
html = open(html_path).read
50+
examples = html.match(/(\d+) examples/)[0].to_i rescue 0
51+
failures = html.match(/(\d+) failures/)[0].to_i rescue 0
52+
pending = html.match(/(\d+) pending/)[0].to_i rescue 0
53+
54+
if failures.zero?
55+
puts "0 failures! #{examples} run, #{pending} pending"
56+
else
57+
puts "\aDID NOT COMMIT YOUR FILES!"
58+
puts "View spec results at #{File.expand_path(html_path)}"
59+
puts
60+
puts "#{failures} failures! #{examples} run, #{pending} pending"
61+
exit 1
62+
end
63+
64+
* http://probablycorey.wordpress.com/2008/03/07/git-hooks-make-me-giddy/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
## Recovering Corrupted Objects ##
22

3+
[Recovering Lost Commits Blog Post](http://programblings.com/2008/06/07/the-illustrated-guide-to-recovering-lost-commits-with-git)
4+
5+
[Recovering Corrupted Blobs by Linus](http://www.kernel.org/pub/software/scm/git/docs/howto/recover-corrupted-blob-object.txt)

0 commit comments

Comments
 (0)