comparison local/git-quick.html @ 90:1d853842db62

Add an index with anchor tags to jump to sections.
author Rob Landley <rob@landley.net>
date Fri, 09 Nov 2007 19:56:05 -0600
parents 307408bf8982
children 1bd46b3c996d
comparison
equal deleted inserted replaced
89:ac8a8db09cd1 90:1d853842db62
1 <title>Following Linux kernel development with git</title> 1 <title>Following Linux kernel development with git</title>
2 2
3 <h2>A "git bisect HOWTO" with a few extras.</h2> 3 <ul>
4 <li><a href="#what">A "git bisect HOWTO" with a few extras.</a></li>
5 <li><a href="#installing">Installing git</a></li>
6 <li><a href="#downloading">Downloading the kernel with git</a></li>
7 <li><a href="#updating">Updating your local copy</a></li>
8 <li><a href="#looking">Looking at historical versions</a></li>
9 <li><a href="#versions">Working with historical versions<a></li>
10 <li><a href="#diff">Using git diff</a></li>
11 <li><a href="#tarballs">Creating tarballs</a></li>
12 <li><a href="#bisect">Bisect</a></li>
13 <li><a href="#example">Example git bisect run</a></li>
14 <li><a href="#commands">Command summary</a></li>
15 <li><a href="#linus">Linus Tovalds talks about git</a></li>
16 </ul>
17
18 <a name="what><h2>A "git bisect HOWTO" with a few extras.</h2>
4 19
5 <p>This document tells you how to follow Linux kernel development (and 20 <p>This document tells you how to follow Linux kernel development (and
6 examine its history) with git. It does not assume you've ever used a source 21 examine its history) with git. It does not assume you've ever used a source
7 control system before, nor does it assume that you're familiar with 22 control system before, nor does it assume that you're familiar with
8 "distributed" vs "centralized" source control systems.</p> 23 "distributed" vs "centralized" source control systems.</p>
14 submit them back to the kernel developers through git, you'll need 29 submit them back to the kernel developers through git, you'll need
15 <a href=http://www.kernel.org/pub/software/scm/git/docs/tutorial.html>a much 30 <a href=http://www.kernel.org/pub/software/scm/git/docs/tutorial.html>a much
16 larger tutorial</a> that explains concepts like "branches". This one 31 larger tutorial</a> that explains concepts like "branches". This one
17 shouldn't get in the way of doing that sort of thing, but it doesn't go there.</p> 32 shouldn't get in the way of doing that sort of thing, but it doesn't go there.</p>
18 33
19 <h2>Installing git</h2> 34 <a name="installing"><h2>Installing git</h2>
20 35
21 <p>First, install a recent version of git. (Note that the user interface 36 <p>First, install a recent version of git. (Note that the user interface
22 changed drastically in git-1.5.0, and this page only describes the new 37 changed drastically in git-1.5.0, and this page only describes the new
23 interface.)</p> 38 interface.)</p>
24 39
30 <p>When building from source, the easy way to get the man pages is to download 45 <p>When building from source, the easy way to get the man pages is to download
31 the appropriate git-manpages tarball (at the same URL as the source code) 46 the appropriate git-manpages tarball (at the same URL as the source code)
32 and extract it into /usr/share/man. You want the man pages because "git help" 47 and extract it into /usr/share/man. You want the man pages because "git help"
33 displays them.</p> 48 displays them.</p>
34 49
35 <h2>Downloading the kernel with git</h2> 50 <a name="downloading"><h2>Downloading the kernel with git</h2>
36 51
37 <p>The following command will download the current linux-kernel repository into 52 <p>The following command will download the current linux-kernel repository into
38 a local directory called "linux-git":</p> 53 a local directory called "linux-git":</p>
39 54
40 <blockquote> 55 <blockquote>
60 75
61 <p>(If you forget the URL a git repository came from, it's in the file 76 <p>(If you forget the URL a git repository came from, it's in the file
62 ".git/FETCH_HEAD". Normally you shouldn't need to care, since git remembers 77 ".git/FETCH_HEAD". Normally you shouldn't need to care, since git remembers
63 it.)</p> 78 it.)</p>
64 79
65 <h2>Updating your local copy</h2> 80 <a name="updating"><h2>Updating your local copy</h2>
66 81
67 <p>The command "<b>git pull</b>" downloads all the changes committed to Linus's 82 <p>The command "<b>git pull</b>" downloads all the changes committed to Linus's
68 git repository since the last time you updated your copy, and appends those 83 git repository since the last time you updated your copy, and appends those
69 commits to your copy of the repository (in the .git subdirectory). In addition, 84 commits to your copy of the repository (in the .git subdirectory). In addition,
70 this will automatically update the files in your working copy as appropriate. 85 this will automatically update the files in your working copy as appropriate.
76 Other git commands (log, checkout, tag, blame, etc.) don't need to talk to 91 Other git commands (log, checkout, tag, blame, etc.) don't need to talk to
77 the server, you can work on your laptop without an internet connection (or 92 the server, you can work on your laptop without an internet connection (or
78 with a very slow one) and still have access to the complete revision history 93 with a very slow one) and still have access to the complete revision history
79 you've already downloaded.</p> 94 you've already downloaded.</p>
80 95
81 <h2>Looking at historical versions</h2> 96 <a name="looking"><h2>Looking at historical versions</h2>
82 97
83 <p>The <b>git log</b> command lists the changes recorded in your repository, 98 <p>The <b>git log</b> command lists the changes recorded in your repository,
84 starting with the most recent and working back. The big hexadecimal numbers 99 starting with the most recent and working back. The big hexadecimal numbers
85 are unique identifiers (sha1sum) for each commit. If you want to specify a 100 are unique identifiers (sha1sum) for each commit. If you want to specify a
86 commit, you only need the first few digits, enough to form a unique prefix. 101 commit, you only need the first few digits, enough to form a unique prefix.
99 the current state of a file. It shows each line, prefixed with the commit 114 the current state of a file. It shows each line, prefixed with the commit
100 identifier which last changed that line. (If the default version of <b>git 115 identifier which last changed that line. (If the default version of <b>git
101 blame</b> is difficult to read on an 80 charater terminal, try <b>git blame 116 blame</b> is difficult to read on an 80 charater terminal, try <b>git blame
102 $FILE | sed 's/(.*)//'</b> to see more of the file itself.)</p> 117 $FILE | sed 's/(.*)//'</b> to see more of the file itself.)</p>
103 118
104 <h2>Working with historical versions</h2> 119 <a name="versions"><h2>Working with historical versions</h2>
105 120
106 <p>The <b>git checkout</b> command changes your working copy of the source to a 121 <p>The <b>git checkout</b> command changes your working copy of the source to a
107 specific version. The -f option to checkout backs out any local changes 122 specific version. The -f option to checkout backs out any local changes
108 you've made to the files. The <b>git clean</b> command deletes any extra files 123 you've made to the files. The <b>git clean</b> command deletes any extra files
109 in your working directory (ones which aren't checked into the repository). 124 in your working directory (ones which aren't checked into the repository).
126 <p>If you lose track of which version is currently checked out as your working 141 <p>If you lose track of which version is currently checked out as your working
127 copy, use <b>git log</b> to see the most recent commits to the version you're 142 copy, use <b>git log</b> to see the most recent commits to the version you're
128 looking at, and <b>git log master</b> to compare against the most recent 143 looking at, and <b>git log master</b> to compare against the most recent
129 commits in the repository.</p> 144 commits in the repository.</p>
130 145
131 <h2>Using git diff</h2> 146 <a name="diff"><h2>Using git diff</h2>
132 147
133 <p>The command "git diff" shows differences between git versions. You can 148 <p>The command "git diff" shows differences between git versions. You can
134 ask it to show differences between:</p> 149 ask it to show differences between:</p>
135 <ul> 150 <ul>
136 <li><b>git diff</b> - the current version checked out from the respository and all files in the working directory</li> 151 <li><b>git diff</b> - the current version checked out from the respository and all files in the working directory</li>
154 copied files. Notice that git diff has a special syntax to indicate renamed 169 copied files. Notice that git diff has a special syntax to indicate renamed
155 or copied files, which is much more concise and portable than the traditional 170 or copied files, which is much more concise and portable than the traditional
156 behavior of removing all lines from one file and adding them to another. 171 behavior of removing all lines from one file and adding them to another.
157 (This behavior may become the default in a future version.)</p> 172 (This behavior may become the default in a future version.)</p>
158 173
159 <h2>Creating tarballs</h2> 174 <a name="tarballs"><h2>Creating tarballs</h2>
160 175
161 <p>The <b>git archive $VERSION</b> command creates a tarball (written to 176 <p>The <b>git archive $VERSION</b> command creates a tarball (written to
162 stdout) of the given version. Note that "master" isn't the default here, 177 stdout) of the given version. Note that "master" isn't the default here,
163 you have to specify that if you want the most up-to-date version. 178 you have to specify that if you want the most up-to-date version.
164 You can pipe it through bzip and write it to a file (<b>git archive master | 179 You can pipe it through bzip and write it to a file (<b>git archive master |
187 202
188 <p>Finally, you can build in your git directory, and then clean it up 203 <p>Finally, you can build in your git directory, and then clean it up
189 afterwards with <b>git checkout -f; git clean -d</b>. (Better than 204 afterwards with <b>git checkout -f; git clean -d</b>. (Better than
190 "make distclean".)</p> 205 "make distclean".)</p>
191 206
192 <h2>Bisect</h2> 207 <a name="bisect"><h2>Bisect</h2>
193 208
194 <p>Possibly the most useful thing git does for non-kernel developers is 209 <p>Possibly the most useful thing git does for non-kernel developers is
195 <b>git bisect</b>, which can track down a bug to a specific revision. This 210 <b>git bisect</b>, which can track down a bug to a specific revision. This
196 is a multi-step process which binary searches through the revision history 211 is a multi-step process which binary searches through the revision history
197 to find a specific commit responsible for a testable change in behavior.</p> 212 to find a specific commit responsible for a testable change in behavior.</p>
246 end) do a <b>git bisect replay ../bisect.log</b> to restart from your 261 end) do a <b>git bisect replay ../bisect.log</b> to restart from your
247 saved position, and guess the other way. If you realize after the fact you 262 saved position, and guess the other way. If you realize after the fact you
248 need to back up, the bisect log is an easily editable text file you can 263 need to back up, the bisect log is an easily editable text file you can
249 always chop a few lines off the end of.</p> 264 always chop a few lines off the end of.</p>
250 265
251 <h2>Example git bisect run</h2> 266 <a name="example"><h2>Example git bisect run</h2>
252 267
253 <p>Here is a real git bisect run I did on the <a href=http://qemu.org>qemu</a> 268 <p>Here is a real git bisect run I did on the <a href=http://qemu.org>qemu</a>
254 git repository (git://git.kernel.dk/data/git/qemu) to figure out why 269 git repository (git://git.kernel.dk/data/git/qemu) to figure out why
255 the PowerPC Linux kernel I'd built was hanging during IDE controller 270 the PowerPC Linux kernel I'd built was hanging during IDE controller
256 intiialization under the current development version of qemu-system-ppc 271 intiialization under the current development version of qemu-system-ppc
346 </pre> 361 </pre>
347 </blockquote> 362 </blockquote>
348 363
349 <p> 364 <p>
350 365
351 <h2>Command summary</h2> 366 <a name="commands"><h2>Command summary</h2>
352 367
353 <p><b>git help</b></p> - List available commands. You can also go 368 <p><b>git help</b></p> - List available commands. You can also go
354 <b>git help COMMANDNAME</b> to see help on a specific command. Note, 369 <b>git help COMMANDNAME</b> to see help on a specific command. Note,
355 this displays the man page for the appropriate command, so you need to have 370 this displays the man page for the appropriate command, so you need to have
356 the git man pages installed for it to work.</p> 371 the git man pages installed for it to work.</p>
396 If this causes problems, you can add "--" to the command line to explicitly 411 If this causes problems, you can add "--" to the command line to explicitly
397 specify that arguments before that (if any) are version identifiers and all the 412 specify that arguments before that (if any) are version identifiers and all the
398 arguments after that are filenames. Add "--find-copies-harder" to detect 413 arguments after that are filenames. Add "--find-copies-harder" to detect
399 renames.</p> 414 renames.</p>
400 415
401 <h2>Linus Tovalds talks about git</h2> 416 <a name="linus"><h2>Linus Tovalds talks about git</h2>
402 417
403 <p>In <a href=http://youtube.com/watch?v=4XpnKHJAok8>this Google Tech Talk</a></p> 418 <p>In <a href=http://youtube.com/watch?v=4XpnKHJAok8>this Google Tech Talk</a></p>
404 419
405 <!-- 420 <!--
406 "git show @{163}"... one character less... 421 "git show @{163}"... one character less...