Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" |
| 2 | "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 6 | <meta name="generator" content="AsciiDoc 7.0.2" /> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 7 | <style type="text/css"> |
| 8 | /* Debug borders */ |
| 9 | p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 { |
| 10 | /* |
| 11 | border: 1px solid red; |
| 12 | */ |
| 13 | } |
| 14 | |
| 15 | body { |
| 16 | margin: 1em 5% 1em 5%; |
| 17 | } |
| 18 | |
| 19 | a { color: blue; } |
| 20 | a:visited { color: fuchsia; } |
| 21 | |
| 22 | em { |
| 23 | font-style: italic; |
| 24 | } |
| 25 | |
| 26 | strong { |
| 27 | font-weight: bold; |
| 28 | } |
| 29 | |
| 30 | tt { |
| 31 | color: navy; |
| 32 | } |
| 33 | |
| 34 | h1, h2, h3, h4, h5, h6 { |
| 35 | color: #527bbd; |
| 36 | font-family: sans-serif; |
| 37 | margin-top: 1.2em; |
| 38 | margin-bottom: 0.5em; |
| 39 | line-height: 1.3; |
| 40 | } |
| 41 | |
| 42 | h1 { |
| 43 | border-bottom: 2px solid silver; |
| 44 | } |
| 45 | h2 { |
| 46 | border-bottom: 2px solid silver; |
| 47 | padding-top: 0.5em; |
| 48 | } |
| 49 | |
| 50 | div.sectionbody { |
| 51 | font-family: serif; |
| 52 | margin-left: 0; |
| 53 | } |
| 54 | |
| 55 | hr { |
| 56 | border: 1px solid silver; |
| 57 | } |
| 58 | |
| 59 | p { |
| 60 | margin-top: 0.5em; |
| 61 | margin-bottom: 0.5em; |
| 62 | } |
| 63 | |
| 64 | pre { |
| 65 | padding: 0; |
| 66 | margin: 0; |
| 67 | } |
| 68 | |
| 69 | span#author { |
| 70 | color: #527bbd; |
| 71 | font-family: sans-serif; |
| 72 | font-weight: bold; |
| 73 | font-size: 1.2em; |
| 74 | } |
| 75 | span#email { |
| 76 | } |
| 77 | span#revision { |
| 78 | font-family: sans-serif; |
| 79 | } |
| 80 | |
| 81 | div#footer { |
| 82 | font-family: sans-serif; |
| 83 | font-size: small; |
| 84 | border-top: 2px solid silver; |
| 85 | padding-top: 0.5em; |
| 86 | margin-top: 4.0em; |
| 87 | } |
| 88 | div#footer-text { |
| 89 | float: left; |
| 90 | padding-bottom: 0.5em; |
| 91 | } |
| 92 | div#footer-badges { |
| 93 | float: right; |
| 94 | padding-bottom: 0.5em; |
| 95 | } |
| 96 | |
| 97 | div#preamble, |
| 98 | div.tableblock, div.imageblock, div.exampleblock, div.verseblock, |
| 99 | div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, |
| 100 | div.admonitionblock { |
| 101 | margin-right: 10%; |
| 102 | margin-top: 1.5em; |
| 103 | margin-bottom: 1.5em; |
| 104 | } |
| 105 | div.admonitionblock { |
| 106 | margin-top: 2.5em; |
| 107 | margin-bottom: 2.5em; |
| 108 | } |
| 109 | |
| 110 | div.content { /* Block element content. */ |
| 111 | padding: 0; |
| 112 | } |
| 113 | |
| 114 | /* Block element titles. */ |
| 115 | div.title, caption.title { |
| 116 | font-family: sans-serif; |
| 117 | font-weight: bold; |
| 118 | text-align: left; |
| 119 | margin-top: 1.0em; |
| 120 | margin-bottom: 0.5em; |
| 121 | } |
| 122 | div.title + * { |
| 123 | margin-top: 0; |
| 124 | } |
| 125 | |
| 126 | td div.title:first-child { |
| 127 | margin-top: 0.0em; |
| 128 | } |
| 129 | div.content div.title:first-child { |
| 130 | margin-top: 0.0em; |
| 131 | } |
| 132 | div.content + div.title { |
| 133 | margin-top: 0.0em; |
| 134 | } |
| 135 | |
| 136 | div.sidebarblock > div.content { |
| 137 | background: #ffffee; |
| 138 | border: 1px solid silver; |
| 139 | padding: 0.5em; |
| 140 | } |
| 141 | |
| 142 | div.listingblock > div.content { |
| 143 | border: 1px solid silver; |
| 144 | background: #f4f4f4; |
| 145 | padding: 0.5em; |
| 146 | } |
| 147 | |
| 148 | div.quoteblock > div.content { |
| 149 | padding-left: 2.0em; |
| 150 | } |
| 151 | div.quoteblock .attribution { |
| 152 | text-align: right; |
| 153 | } |
| 154 | |
| 155 | div.admonitionblock .icon { |
| 156 | vertical-align: top; |
| 157 | font-size: 1.1em; |
| 158 | font-weight: bold; |
| 159 | text-decoration: underline; |
| 160 | color: #527bbd; |
| 161 | padding-right: 0.5em; |
| 162 | } |
| 163 | div.admonitionblock td.content { |
| 164 | padding-left: 0.5em; |
| 165 | border-left: 2px solid silver; |
| 166 | } |
| 167 | |
| 168 | div.exampleblock > div.content { |
| 169 | border-left: 2px solid silver; |
| 170 | padding: 0.5em; |
| 171 | } |
| 172 | |
| 173 | div.verseblock div.content { |
| 174 | white-space: pre; |
| 175 | } |
| 176 | |
| 177 | div.imageblock div.content { padding-left: 0; } |
| 178 | div.imageblock img { border: 1px solid silver; } |
| 179 | span.image img { border-style: none; } |
| 180 | |
| 181 | dl { |
| 182 | margin-top: 0.8em; |
| 183 | margin-bottom: 0.8em; |
| 184 | } |
| 185 | dt { |
| 186 | margin-top: 0.5em; |
| 187 | margin-bottom: 0; |
| 188 | font-style: italic; |
| 189 | } |
| 190 | dd > *:first-child { |
| 191 | margin-top: 0; |
| 192 | } |
| 193 | |
| 194 | ul, ol { |
| 195 | list-style-position: outside; |
| 196 | } |
| 197 | ol.olist2 { |
| 198 | list-style-type: lower-alpha; |
| 199 | } |
| 200 | |
| 201 | div.tableblock > table { |
| 202 | border-color: #527bbd; |
| 203 | border-width: 3px; |
| 204 | } |
| 205 | thead { |
| 206 | font-family: sans-serif; |
| 207 | font-weight: bold; |
| 208 | } |
| 209 | tfoot { |
| 210 | font-weight: bold; |
| 211 | } |
| 212 | |
| 213 | div.hlist { |
| 214 | margin-top: 0.8em; |
| 215 | margin-bottom: 0.8em; |
| 216 | } |
| 217 | td.hlist1 { |
| 218 | vertical-align: top; |
| 219 | font-style: italic; |
| 220 | padding-right: 0.8em; |
| 221 | } |
| 222 | td.hlist2 { |
| 223 | vertical-align: top; |
| 224 | } |
| 225 | |
| 226 | @media print { |
| 227 | div#footer-badges { display: none; } |
| 228 | } |
| 229 | /* Workarounds for IE6's broken and incomplete CSS2. */ |
| 230 | |
| 231 | div.sidebar-content { |
| 232 | background: #ffffee; |
| 233 | border: 1px solid silver; |
| 234 | padding: 0.5em; |
| 235 | } |
| 236 | div.sidebar-title, div.image-title { |
| 237 | font-family: sans-serif; |
| 238 | font-weight: bold; |
| 239 | margin-top: 0.0em; |
| 240 | margin-bottom: 0.5em; |
| 241 | } |
| 242 | |
| 243 | div.listingblock div.content { |
| 244 | border: 1px solid silver; |
| 245 | background: #f4f4f4; |
| 246 | padding: 0.5em; |
| 247 | } |
| 248 | |
| 249 | div.quoteblock-content { |
| 250 | padding-left: 2.0em; |
| 251 | } |
| 252 | |
| 253 | div.exampleblock-content { |
| 254 | border-left: 2px solid silver; |
| 255 | padding-left: 0.5em; |
| 256 | } |
| 257 | </style> |
| 258 | <title>Everyday GIT With 20 Commands Or So</title> |
| 259 | </head> |
| 260 | <body> |
| 261 | <div id="header"> |
| 262 | <h1>Everyday GIT With 20 Commands Or So</h1> |
| 263 | </div> |
| 264 | <div id="preamble"> |
| 265 | <div class="sectionbody"> |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 266 | <p><a href="#Basic Repository">[Basic Repository]</a> commands are needed by people who have a |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 267 | repository --- that is everybody, because every working tree of |
| 268 | git is a repository.</p> |
| 269 | <p>In addition, <a href="#Individual Developer (Standalone)">[Individual Developer (Standalone)]</a> commands are |
| 270 | essential for anybody who makes a commit, even for somebody who |
| 271 | works alone.</p> |
| 272 | <p>If you work with other people, you will need commands listed in |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 273 | the <a href="#Individual Developer (Participant)">[Individual Developer (Participant)]</a> section as well.</p> |
| 274 | <p>People who play the <a href="#Integrator">[Integrator]</a> role need to learn some more |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 275 | commands in addition to the above.</p> |
| 276 | <p><a href="#Repository Administration">[Repository Administration]</a> commands are for system |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 277 | administrators who are responsible for the care and feeding |
| 278 | of git repositories.</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 279 | </div> |
| 280 | </div> |
| 281 | <h2>Basic Repository<a id="Basic Repository"></a></h2> |
| 282 | <div class="sectionbody"> |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 283 | <p>Everybody uses these commands to maintain git repositories.</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 284 | <ul> |
| 285 | <li> |
| 286 | <p> |
Junio C Hamano | fc4d38c | 2007-01-08 06:53:32 | [diff] [blame] | 287 | <a href="git-init.html">git-init(1)</a> or <a href="git-clone.html">git-clone(1)</a> to create a |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 288 | new repository. |
| 289 | </p> |
| 290 | </li> |
| 291 | <li> |
| 292 | <p> |
Junio C Hamano | 7ad22dc | 2007-01-29 02:55:48 | [diff] [blame] | 293 | <a href="git-fsck.html">git-fsck(1)</a> to check the repository for errors. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 294 | </p> |
| 295 | </li> |
| 296 | <li> |
| 297 | <p> |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 298 | <a href="git-prune.html">git-prune(1)</a> to remove unused objects in the repository. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 299 | </p> |
| 300 | </li> |
| 301 | <li> |
| 302 | <p> |
| 303 | <a href="git-repack.html">git-repack(1)</a> to pack loose objects for efficiency. |
| 304 | </p> |
| 305 | </li> |
Junio C Hamano | 5229946 | 2006-12-28 00:59:38 | [diff] [blame] | 306 | <li> |
| 307 | <p> |
| 308 | <a href="git-gc.html">git-gc(1)</a> to do common housekeeping tasks such as |
| 309 | repack and prune. |
| 310 | </p> |
| 311 | </li> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 312 | </ul> |
| 313 | <h3>Examples</h3> |
| 314 | <dl> |
| 315 | <dt> |
| 316 | Check health and remove cruft. |
| 317 | </dt> |
| 318 | <dd> |
| 319 | <div class="listingblock"> |
| 320 | <div class="content"> |
Junio C Hamano | 7ad22dc | 2007-01-29 02:55:48 | [diff] [blame] | 321 | <pre><tt>$ git fsck <b>(1)</b> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 322 | $ git count-objects <b>(2)</b> |
| 323 | $ git repack <b>(3)</b> |
Junio C Hamano | 5229946 | 2006-12-28 00:59:38 | [diff] [blame] | 324 | $ git gc <b>(4)</b></tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 325 | </div></div> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 326 | <ol> |
| 327 | <li> |
| 328 | <p> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 329 | running without <tt>--full</tt> is usually cheap and assures the |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 330 | repository health reasonably well. |
| 331 | </p> |
| 332 | </li> |
| 333 | <li> |
| 334 | <p> |
| 335 | check how many loose objects there are and how much |
Junio C Hamano | bb8fb05 | 2006-05-30 07:21:12 | [diff] [blame] | 336 | disk space is wasted by not repacking. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 337 | </p> |
| 338 | </li> |
| 339 | <li> |
| 340 | <p> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 341 | without <tt>-a</tt> repacks incrementally. repacking every 4-5MB |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 342 | of loose objects accumulation may be a good rule of thumb. |
| 343 | </p> |
| 344 | </li> |
| 345 | <li> |
| 346 | <p> |
Junio C Hamano | 5229946 | 2006-12-28 00:59:38 | [diff] [blame] | 347 | it is easier to use <tt>git gc</tt> than individual housekeeping commands |
| 348 | such as <tt>prune</tt> and <tt>repack</tt>. This runs <tt>repack -a -d</tt>. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 349 | </p> |
| 350 | </li> |
| 351 | </ol> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 352 | </dd> |
| 353 | <dt> |
| 354 | Repack a small project into single pack. |
| 355 | </dt> |
| 356 | <dd> |
| 357 | <div class="listingblock"> |
| 358 | <div class="content"> |
| 359 | <pre><tt>$ git repack -a -d <b>(1)</b> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 360 | $ git prune</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 361 | </div></div> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 362 | <ol> |
| 363 | <li> |
| 364 | <p> |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 365 | pack all the objects reachable from the refs into one pack, |
| 366 | then remove the other packs. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 367 | </p> |
| 368 | </li> |
| 369 | </ol> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 370 | </dd> |
| 371 | </dl> |
| 372 | </div> |
| 373 | <h2>Individual Developer (Standalone)<a id="Individual Developer (Standalone)"></a></h2> |
| 374 | <div class="sectionbody"> |
| 375 | <p>A standalone individual developer does not exchange patches with |
Junio C Hamano | bb8fb05 | 2006-05-30 07:21:12 | [diff] [blame] | 376 | other people, and works alone in a single repository, using the |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 377 | following commands.</p> |
| 378 | <ul> |
| 379 | <li> |
| 380 | <p> |
| 381 | <a href="git-show-branch.html">git-show-branch(1)</a> to see where you are. |
| 382 | </p> |
| 383 | </li> |
| 384 | <li> |
| 385 | <p> |
| 386 | <a href="git-log.html">git-log(1)</a> to see what happened. |
| 387 | </p> |
| 388 | </li> |
| 389 | <li> |
| 390 | <p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 391 | <a href="git-checkout.html">git-checkout(1)</a> and <a href="git-branch.html">git-branch(1)</a> to switch |
| 392 | branches. |
| 393 | </p> |
| 394 | </li> |
| 395 | <li> |
| 396 | <p> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 397 | <a href="git-add.html">git-add(1)</a> to manage the index file. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 398 | </p> |
| 399 | </li> |
| 400 | <li> |
| 401 | <p> |
| 402 | <a href="git-diff.html">git-diff(1)</a> and <a href="git-status.html">git-status(1)</a> to see what |
| 403 | you are in the middle of doing. |
| 404 | </p> |
| 405 | </li> |
| 406 | <li> |
| 407 | <p> |
| 408 | <a href="git-commit.html">git-commit(1)</a> to advance the current branch. |
| 409 | </p> |
| 410 | </li> |
| 411 | <li> |
| 412 | <p> |
| 413 | <a href="git-reset.html">git-reset(1)</a> and <a href="git-checkout.html">git-checkout(1)</a> (with |
| 414 | pathname parameters) to undo changes. |
| 415 | </p> |
| 416 | </li> |
| 417 | <li> |
| 418 | <p> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 419 | <a href="git-merge.html">git-merge(1)</a> to merge between local branches. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 420 | </p> |
| 421 | </li> |
| 422 | <li> |
| 423 | <p> |
| 424 | <a href="git-rebase.html">git-rebase(1)</a> to maintain topic branches. |
| 425 | </p> |
| 426 | </li> |
| 427 | <li> |
| 428 | <p> |
| 429 | <a href="git-tag.html">git-tag(1)</a> to mark known point. |
| 430 | </p> |
| 431 | </li> |
| 432 | </ul> |
| 433 | <h3>Examples</h3> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 434 | <dl> |
| 435 | <dt> |
| 436 | Use a tarball as a starting point for a new repository. |
| 437 | </dt> |
| 438 | <dd> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 439 | <div class="listingblock"> |
| 440 | <div class="content"> |
| 441 | <pre><tt>$ tar zxf frotz.tar.gz |
| 442 | $ cd frotz |
Junio C Hamano | fc4d38c | 2007-01-08 06:53:32 | [diff] [blame] | 443 | $ git-init |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 444 | $ git add . <b>(1)</b> |
| 445 | $ git commit -m 'import of frotz source tree.' |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 446 | $ git tag v2.43 <b>(2)</b></tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 447 | </div></div> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 448 | <ol> |
| 449 | <li> |
| 450 | <p> |
| 451 | add everything under the current directory. |
| 452 | </p> |
| 453 | </li> |
| 454 | <li> |
| 455 | <p> |
| 456 | make a lightweight, unannotated tag. |
| 457 | </p> |
| 458 | </li> |
| 459 | </ol> |
| 460 | </dd> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 461 | <dt> |
| 462 | Create a topic branch and develop. |
| 463 | </dt> |
| 464 | <dd> |
| 465 | <div class="listingblock"> |
| 466 | <div class="content"> |
| 467 | <pre><tt>$ git checkout -b alsa-audio <b>(1)</b> |
| 468 | $ edit/compile/test |
| 469 | $ git checkout -- curses/ux_audio_oss.c <b>(2)</b> |
| 470 | $ git add curses/ux_audio_alsa.c <b>(3)</b> |
| 471 | $ edit/compile/test |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 472 | $ git diff HEAD <b>(4)</b> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 473 | $ git commit -a -s <b>(5)</b> |
| 474 | $ edit/compile/test |
| 475 | $ git reset --soft HEAD^ <b>(6)</b> |
| 476 | $ edit/compile/test |
| 477 | $ git diff ORIG_HEAD <b>(7)</b> |
| 478 | $ git commit -a -c ORIG_HEAD <b>(8)</b> |
| 479 | $ git checkout master <b>(9)</b> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 480 | $ git merge alsa-audio <b>(10)</b> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 481 | $ git log --since='3 days ago' <b>(11)</b> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 482 | $ git log v2.43.. curses/ <b>(12)</b></tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 483 | </div></div> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 484 | <ol> |
| 485 | <li> |
| 486 | <p> |
| 487 | create a new topic branch. |
| 488 | </p> |
| 489 | </li> |
| 490 | <li> |
| 491 | <p> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 492 | revert your botched changes in <tt>curses/ux_audio_oss.c</tt>. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 493 | </p> |
| 494 | </li> |
| 495 | <li> |
| 496 | <p> |
| 497 | you need to tell git if you added a new file; removal and |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 498 | modification will be caught if you do <tt>git commit -a</tt> later. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 499 | </p> |
| 500 | </li> |
| 501 | <li> |
| 502 | <p> |
| 503 | to see what changes you are committing. |
| 504 | </p> |
| 505 | </li> |
| 506 | <li> |
| 507 | <p> |
| 508 | commit everything as you have tested, with your sign-off. |
| 509 | </p> |
| 510 | </li> |
| 511 | <li> |
| 512 | <p> |
| 513 | take the last commit back, keeping what is in the working tree. |
| 514 | </p> |
| 515 | </li> |
| 516 | <li> |
| 517 | <p> |
| 518 | look at the changes since the premature commit we took back. |
| 519 | </p> |
| 520 | </li> |
| 521 | <li> |
| 522 | <p> |
| 523 | redo the commit undone in the previous step, using the message |
| 524 | you originally wrote. |
| 525 | </p> |
| 526 | </li> |
| 527 | <li> |
| 528 | <p> |
| 529 | switch to the master branch. |
| 530 | </p> |
| 531 | </li> |
| 532 | <li> |
| 533 | <p> |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 534 | merge a topic branch into your master branch. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 535 | </p> |
| 536 | </li> |
| 537 | <li> |
| 538 | <p> |
| 539 | review commit logs; other forms to limit output can be |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 540 | combined and include <tt>--max-count=10</tt> (show 10 commits), |
| 541 | <tt>--until=2005-12-10</tt>, etc. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 542 | </p> |
| 543 | </li> |
| 544 | <li> |
| 545 | <p> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 546 | view only the changes that touch what's in <tt>curses/</tt> |
| 547 | directory, since <tt>v2.43</tt> tag. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 548 | </p> |
| 549 | </li> |
| 550 | </ol> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 551 | </dd> |
| 552 | </dl> |
| 553 | </div> |
| 554 | <h2>Individual Developer (Participant)<a id="Individual Developer (Participant)"></a></h2> |
| 555 | <div class="sectionbody"> |
| 556 | <p>A developer working as a participant in a group project needs to |
| 557 | learn how to communicate with others, and uses these commands in |
| 558 | addition to the ones needed by a standalone developer.</p> |
| 559 | <ul> |
| 560 | <li> |
| 561 | <p> |
| 562 | <a href="git-clone.html">git-clone(1)</a> from the upstream to prime your local |
| 563 | repository. |
| 564 | </p> |
| 565 | </li> |
| 566 | <li> |
| 567 | <p> |
| 568 | <a href="git-pull.html">git-pull(1)</a> and <a href="git-fetch.html">git-fetch(1)</a> from "origin" |
| 569 | to keep up-to-date with the upstream. |
| 570 | </p> |
| 571 | </li> |
| 572 | <li> |
| 573 | <p> |
| 574 | <a href="git-push.html">git-push(1)</a> to shared repository, if you adopt CVS |
| 575 | style shared repository workflow. |
| 576 | </p> |
| 577 | </li> |
| 578 | <li> |
| 579 | <p> |
| 580 | <a href="git-format-patch.html">git-format-patch(1)</a> to prepare e-mail submission, if |
| 581 | you adopt Linux kernel-style public forum workflow. |
| 582 | </p> |
| 583 | </li> |
| 584 | </ul> |
| 585 | <h3>Examples</h3> |
| 586 | <dl> |
| 587 | <dt> |
| 588 | Clone the upstream and work on it. Feed changes to upstream. |
| 589 | </dt> |
| 590 | <dd> |
| 591 | <div class="listingblock"> |
| 592 | <div class="content"> |
| 593 | <pre><tt>$ git clone git://git.kernel.org/pub/scm/.../torvalds/linux-2.6 my2.6 |
| 594 | $ cd my2.6 |
| 595 | $ edit/compile/test; git commit -a -s <b>(1)</b> |
| 596 | $ git format-patch origin <b>(2)</b> |
| 597 | $ git pull <b>(3)</b> |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 598 | $ git log -p ORIG_HEAD.. arch/i386 include/asm-i386 <b>(4)</b> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 599 | $ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <b>(5)</b> |
| 600 | $ git reset --hard ORIG_HEAD <b>(6)</b> |
| 601 | $ git prune <b>(7)</b> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 602 | $ git fetch --tags <b>(8)</b></tt></pre> |
| 603 | </div></div> |
| 604 | <ol> |
| 605 | <li> |
| 606 | <p> |
| 607 | repeat as needed. |
| 608 | </p> |
| 609 | </li> |
| 610 | <li> |
| 611 | <p> |
| 612 | extract patches from your branch for e-mail submission. |
| 613 | </p> |
| 614 | </li> |
| 615 | <li> |
| 616 | <p> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 617 | <tt>git pull</tt> fetches from <tt>origin</tt> by default and merges into the |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 618 | current branch. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 619 | </p> |
| 620 | </li> |
| 621 | <li> |
| 622 | <p> |
| 623 | immediately after pulling, look at the changes done upstream |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 624 | since last time we checked, only in the |
| 625 | area we are interested in. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 626 | </p> |
| 627 | </li> |
| 628 | <li> |
| 629 | <p> |
| 630 | fetch from a specific branch from a specific repository and merge. |
| 631 | </p> |
| 632 | </li> |
| 633 | <li> |
| 634 | <p> |
| 635 | revert the pull. |
| 636 | </p> |
| 637 | </li> |
| 638 | <li> |
| 639 | <p> |
| 640 | garbage collect leftover objects from reverted pull. |
| 641 | </p> |
| 642 | </li> |
| 643 | <li> |
| 644 | <p> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 645 | from time to time, obtain official tags from the <tt>origin</tt> |
| 646 | and store them under <tt>.git/refs/tags/</tt>. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 647 | </p> |
| 648 | </li> |
| 649 | </ol> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 650 | </dd> |
| 651 | <dt> |
| 652 | Push into another repository. |
| 653 | </dt> |
| 654 | <dd> |
| 655 | <div class="listingblock"> |
| 656 | <div class="content"> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 657 | <pre><tt>satellite$ git clone mothership:frotz frotz <b>(1)</b> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 658 | satellite$ cd frotz |
Junio C Hamano | 7ad22dc | 2007-01-29 02:55:48 | [diff] [blame] | 659 | satellite$ git config --get-regexp '^(remote|branch)\.' <b>(2)</b> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 660 | remote.origin.url mothership:frotz |
| 661 | remote.origin.fetch refs/heads/*:refs/remotes/origin/* |
| 662 | branch.master.remote origin |
| 663 | branch.master.merge refs/heads/master |
Junio C Hamano | 7ad22dc | 2007-01-29 02:55:48 | [diff] [blame] | 664 | satellite$ git config remote.origin.push \ |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 665 | master:refs/remotes/satellite/master <b>(3)</b> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 666 | satellite$ edit/compile/test/commit |
| 667 | satellite$ git push origin <b>(4)</b> |
| 668 | |
| 669 | mothership$ cd frotz |
| 670 | mothership$ git checkout master |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 671 | mothership$ git merge satellite/master <b>(5)</b></tt></pre> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 672 | </div></div> |
| 673 | <ol> |
| 674 | <li> |
| 675 | <p> |
| 676 | mothership machine has a frotz repository under your home |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 677 | directory; clone from it to start a repository on the satellite |
| 678 | machine. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 679 | </p> |
| 680 | </li> |
| 681 | <li> |
| 682 | <p> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 683 | clone sets these configuration variables by default. |
| 684 | It arranges <tt>git pull</tt> to fetch and store the branches of mothership |
| 685 | machine to local <tt>remotes/origin/*</tt> tracking branches. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 686 | </p> |
| 687 | </li> |
| 688 | <li> |
| 689 | <p> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 690 | arrange <tt>git push</tt> to push local <tt>master</tt> branch to |
| 691 | <tt>remotes/satellite/master</tt> branch of the mothership machine. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 692 | </p> |
| 693 | </li> |
| 694 | <li> |
| 695 | <p> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 696 | push will stash our work away on <tt>remotes/satellite/master</tt> |
| 697 | tracking branch on the mothership machine. You could use this as |
| 698 | a back-up method. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 699 | </p> |
| 700 | </li> |
| 701 | <li> |
| 702 | <p> |
| 703 | on mothership machine, merge the work done on the satellite |
| 704 | machine into the master branch. |
| 705 | </p> |
| 706 | </li> |
| 707 | </ol> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 708 | </dd> |
| 709 | <dt> |
| 710 | Branch off of a specific tag. |
| 711 | </dt> |
| 712 | <dd> |
| 713 | <div class="listingblock"> |
| 714 | <div class="content"> |
| 715 | <pre><tt>$ git checkout -b private2.6.14 v2.6.14 <b>(1)</b> |
| 716 | $ edit/compile/test; git commit -a |
| 717 | $ git checkout master |
| 718 | $ git format-patch -k -m --stdout v2.6.14..private2.6.14 | |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 719 | git am -3 -k <b>(2)</b></tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 720 | </div></div> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 721 | <ol> |
| 722 | <li> |
| 723 | <p> |
| 724 | create a private branch based on a well known (but somewhat behind) |
| 725 | tag. |
| 726 | </p> |
| 727 | </li> |
| 728 | <li> |
| 729 | <p> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 730 | forward port all changes in <tt>private2.6.14</tt> branch to <tt>master</tt> branch |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 731 | without a formal "merging". |
| 732 | </p> |
| 733 | </li> |
| 734 | </ol> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 735 | </dd> |
| 736 | </dl> |
| 737 | </div> |
| 738 | <h2>Integrator<a id="Integrator"></a></h2> |
| 739 | <div class="sectionbody"> |
| 740 | <p>A fairly central person acting as the integrator in a group |
| 741 | project receives changes made by others, reviews and integrates |
| 742 | them and publishes the result for others to use, using these |
| 743 | commands in addition to the ones needed by participants.</p> |
| 744 | <ul> |
| 745 | <li> |
| 746 | <p> |
| 747 | <a href="git-am.html">git-am(1)</a> to apply patches e-mailed in from your |
| 748 | contributors. |
| 749 | </p> |
| 750 | </li> |
| 751 | <li> |
| 752 | <p> |
| 753 | <a href="git-pull.html">git-pull(1)</a> to merge from your trusted lieutenants. |
| 754 | </p> |
| 755 | </li> |
| 756 | <li> |
| 757 | <p> |
| 758 | <a href="git-format-patch.html">git-format-patch(1)</a> to prepare and send suggested |
| 759 | alternative to contributors. |
| 760 | </p> |
| 761 | </li> |
| 762 | <li> |
| 763 | <p> |
| 764 | <a href="git-revert.html">git-revert(1)</a> to undo botched commits. |
| 765 | </p> |
| 766 | </li> |
| 767 | <li> |
| 768 | <p> |
| 769 | <a href="git-push.html">git-push(1)</a> to publish the bleeding edge. |
| 770 | </p> |
| 771 | </li> |
| 772 | </ul> |
| 773 | <h3>Examples</h3> |
| 774 | <dl> |
| 775 | <dt> |
| 776 | My typical GIT day. |
| 777 | </dt> |
| 778 | <dd> |
| 779 | <div class="listingblock"> |
| 780 | <div class="content"> |
| 781 | <pre><tt>$ git status <b>(1)</b> |
| 782 | $ git show-branch <b>(2)</b> |
| 783 | $ mailx <b>(3)</b> |
| 784 | & s 2 3 4 5 ./+to-apply |
| 785 | & s 7 8 ./+hold-linus |
| 786 | & q |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 787 | $ git checkout -b topic/one master |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 788 | $ git am -3 -i -s -u ./+to-apply <b>(4)</b> |
| 789 | $ compile/test |
| 790 | $ git checkout -b hold/linus && git am -3 -i -s -u ./+hold-linus <b>(5)</b> |
| 791 | $ git checkout topic/one && git rebase master <b>(6)</b> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 792 | $ git checkout pu && git reset --hard next <b>(7)</b> |
| 793 | $ git merge topic/one topic/two && git merge hold/linus <b>(8)</b> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 794 | $ git checkout maint |
| 795 | $ git cherry-pick master~4 <b>(9)</b> |
| 796 | $ compile/test |
| 797 | $ git tag -s -m 'GIT 0.99.9x' v0.99.9x <b>(10)</b> |
| 798 | $ git fetch ko && git show-branch master maint 'tags/ko-*' <b>(11)</b> |
| 799 | $ git push ko <b>(12)</b> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 800 | $ git push ko v0.99.9x <b>(13)</b></tt></pre> |
| 801 | </div></div> |
| 802 | <ol> |
| 803 | <li> |
| 804 | <p> |
| 805 | see what I was in the middle of doing, if any. |
| 806 | </p> |
| 807 | </li> |
| 808 | <li> |
| 809 | <p> |
| 810 | see what topic branches I have and think about how ready |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 811 | they are. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 812 | </p> |
| 813 | </li> |
| 814 | <li> |
| 815 | <p> |
| 816 | read mails, save ones that are applicable, and save others |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 817 | that are not quite ready. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 818 | </p> |
| 819 | </li> |
| 820 | <li> |
| 821 | <p> |
| 822 | apply them, interactively, with my sign-offs. |
| 823 | </p> |
| 824 | </li> |
| 825 | <li> |
| 826 | <p> |
| 827 | create topic branch as needed and apply, again with my |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 828 | sign-offs. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 829 | </p> |
| 830 | </li> |
| 831 | <li> |
| 832 | <p> |
| 833 | rebase internal topic branch that has not been merged to the |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 834 | master, nor exposed as a part of a stable branch. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 835 | </p> |
| 836 | </li> |
| 837 | <li> |
| 838 | <p> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 839 | restart <tt>pu</tt> every time from the next. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 840 | </p> |
| 841 | </li> |
| 842 | <li> |
| 843 | <p> |
| 844 | and bundle topic branches still cooking. |
| 845 | </p> |
| 846 | </li> |
| 847 | <li> |
| 848 | <p> |
| 849 | backport a critical fix. |
| 850 | </p> |
| 851 | </li> |
| 852 | <li> |
| 853 | <p> |
| 854 | create a signed tag. |
| 855 | </p> |
| 856 | </li> |
| 857 | <li> |
| 858 | <p> |
| 859 | make sure I did not accidentally rewind master beyond what I |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 860 | already pushed out. <tt>ko</tt> shorthand points at the repository I have |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 861 | at kernel.org, and looks like this: |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 862 | </p> |
Junio C Hamano | 7da87bb | 2006-06-06 01:23:49 | [diff] [blame] | 863 | <div class="listingblock"> |
| 864 | <div class="content"> |
| 865 | <pre><tt>$ cat .git/remotes/ko |
| 866 | URL: kernel.org:/pub/scm/git/git.git |
| 867 | Pull: master:refs/tags/ko-master |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 868 | Pull: next:refs/tags/ko-next |
Junio C Hamano | 7da87bb | 2006-06-06 01:23:49 | [diff] [blame] | 869 | Pull: maint:refs/tags/ko-maint |
| 870 | Push: master |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 871 | Push: next |
Junio C Hamano | 7da87bb | 2006-06-06 01:23:49 | [diff] [blame] | 872 | Push: +pu |
| 873 | Push: maint</tt></pre> |
| 874 | </div></div> |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 875 | <p>In the output from <tt>git show-branch</tt>, <tt>master</tt> should have |
| 876 | everything <tt>ko-master</tt> has, and <tt>next</tt> should have |
| 877 | everything <tt>ko-next</tt> has.</p> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 878 | </li> |
| 879 | <li> |
| 880 | <p> |
| 881 | push out the bleeding edge. |
| 882 | </p> |
| 883 | </li> |
| 884 | <li> |
| 885 | <p> |
| 886 | push the tag out, too. |
| 887 | </p> |
| 888 | </li> |
| 889 | </ol> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 890 | </dd> |
| 891 | </dl> |
| 892 | </div> |
| 893 | <h2>Repository Administration<a id="Repository Administration"></a></h2> |
| 894 | <div class="sectionbody"> |
| 895 | <p>A repository administrator uses the following tools to set up |
| 896 | and maintain access to the repository by developers.</p> |
| 897 | <ul> |
| 898 | <li> |
| 899 | <p> |
| 900 | <a href="git-daemon.html">git-daemon(1)</a> to allow anonymous download from |
| 901 | repository. |
| 902 | </p> |
| 903 | </li> |
| 904 | <li> |
| 905 | <p> |
| 906 | <a href="git-shell.html">git-shell(1)</a> can be used as a <em>restricted login shell</em> |
| 907 | for shared central repository users. |
| 908 | </p> |
| 909 | </li> |
| 910 | </ul> |
| 911 | <p><a href="howto/update-hook-example.txt">update hook howto</a> has a good |
| 912 | example of managing a shared central repository.</p> |
| 913 | <h3>Examples</h3> |
| 914 | <dl> |
| 915 | <dt> |
Junio C Hamano | a053d54 | 2006-10-27 09:29:13 | [diff] [blame] | 916 | We assume the following in /etc/services |
| 917 | </dt> |
| 918 | <dd> |
| 919 | <div class="listingblock"> |
| 920 | <div class="content"> |
| 921 | <pre><tt>$ grep 9418 /etc/services |
| 922 | git 9418/tcp # Git Version Control System</tt></pre> |
| 923 | </div></div> |
| 924 | </dd> |
| 925 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 926 | Run git-daemon to serve /pub/scm from inetd. |
| 927 | </dt> |
| 928 | <dd> |
| 929 | <div class="listingblock"> |
| 930 | <div class="content"> |
Junio C Hamano | bb8fb05 | 2006-05-30 07:21:12 | [diff] [blame] | 931 | <pre><tt>$ grep git /etc/inetd.conf |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 932 | git stream tcp nowait nobody \ |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 933 | /usr/bin/git-daemon git-daemon --inetd --export-all /pub/scm</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 934 | </div></div> |
| 935 | <p>The actual configuration line should be on one line.</p> |
| 936 | </dd> |
| 937 | <dt> |
Junio C Hamano | 7da87bb | 2006-06-06 01:23:49 | [diff] [blame] | 938 | Run git-daemon to serve /pub/scm from xinetd. |
| 939 | </dt> |
| 940 | <dd> |
| 941 | <div class="listingblock"> |
| 942 | <div class="content"> |
| 943 | <pre><tt>$ cat /etc/xinetd.d/git-daemon |
| 944 | # default: off |
| 945 | # description: The git server offers access to git repositories |
| 946 | service git |
| 947 | { |
| 948 | disable = no |
| 949 | type = UNLISTED |
| 950 | port = 9418 |
| 951 | socket_type = stream |
| 952 | wait = no |
| 953 | user = nobody |
| 954 | server = /usr/bin/git-daemon |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 955 | server_args = --inetd --export-all --base-path=/pub/scm |
Junio C Hamano | 7da87bb | 2006-06-06 01:23:49 | [diff] [blame] | 956 | log_on_failure += USERID |
| 957 | }</tt></pre> |
| 958 | </div></div> |
| 959 | <p>Check your xinetd(8) documentation and setup, this is from a Fedora system. |
| 960 | Others might be different.</p> |
| 961 | </dd> |
| 962 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 963 | Give push/pull only access to developers. |
| 964 | </dt> |
| 965 | <dd> |
| 966 | <div class="listingblock"> |
| 967 | <div class="content"> |
| 968 | <pre><tt>$ grep git /etc/passwd <b>(1)</b> |
| 969 | alice:x:1000:1000::/home/alice:/usr/bin/git-shell |
| 970 | bob:x:1001:1001::/home/bob:/usr/bin/git-shell |
| 971 | cindy:x:1002:1002::/home/cindy:/usr/bin/git-shell |
| 972 | david:x:1003:1003::/home/david:/usr/bin/git-shell |
| 973 | $ grep git /etc/shells <b>(2)</b> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 974 | /usr/bin/git-shell</tt></pre> |
| 975 | </div></div> |
| 976 | <ol> |
| 977 | <li> |
| 978 | <p> |
| 979 | log-in shell is set to /usr/bin/git-shell, which does not |
Junio C Hamano | 7464064 | 2006-12-27 10:59:55 | [diff] [blame] | 980 | allow anything but <tt>git push</tt> and <tt>git pull</tt>. The users should |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 981 | get an ssh access to the machine. |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 982 | </p> |
| 983 | </li> |
| 984 | <li> |
| 985 | <p> |
| 986 | in many distributions /etc/shells needs to list what is used |
| 987 | as the login shell. |
| 988 | </p> |
| 989 | </li> |
| 990 | </ol> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 991 | </dd> |
| 992 | <dt> |
| 993 | CVS-style shared repository. |
| 994 | </dt> |
| 995 | <dd> |
| 996 | <div class="listingblock"> |
| 997 | <div class="content"> |
| 998 | <pre><tt>$ grep git /etc/group <b>(1)</b> |
| 999 | git:x:9418:alice,bob,cindy,david |
| 1000 | $ cd /home/devo.git |
| 1001 | $ ls -l <b>(2)</b> |
| 1002 | lrwxrwxrwx 1 david git 17 Dec 4 22:40 HEAD -> refs/heads/master |
| 1003 | drwxrwsr-x 2 david git 4096 Dec 4 22:40 branches |
| 1004 | -rw-rw-r-- 1 david git 84 Dec 4 22:40 config |
| 1005 | -rw-rw-r-- 1 david git 58 Dec 4 22:40 description |
| 1006 | drwxrwsr-x 2 david git 4096 Dec 4 22:40 hooks |
| 1007 | -rw-rw-r-- 1 david git 37504 Dec 4 22:40 index |
| 1008 | drwxrwsr-x 2 david git 4096 Dec 4 22:40 info |
| 1009 | drwxrwsr-x 4 david git 4096 Dec 4 22:40 objects |
| 1010 | drwxrwsr-x 4 david git 4096 Nov 7 14:58 refs |
| 1011 | drwxrwsr-x 2 david git 4096 Dec 4 22:40 remotes |
| 1012 | $ ls -l hooks/update <b>(3)</b> |
| 1013 | -r-xr-xr-x 1 david git 3536 Dec 4 22:40 update |
| 1014 | $ cat info/allowed-users <b>(4)</b> |
| 1015 | refs/heads/master alice\|cindy |
| 1016 | refs/heads/doc-update bob |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1017 | refs/tags/v[0-9]* david</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1018 | </div></div> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1019 | <ol> |
| 1020 | <li> |
| 1021 | <p> |
| 1022 | place the developers into the same git group. |
| 1023 | </p> |
| 1024 | </li> |
| 1025 | <li> |
| 1026 | <p> |
| 1027 | and make the shared repository writable by the group. |
| 1028 | </p> |
| 1029 | </li> |
| 1030 | <li> |
| 1031 | <p> |
| 1032 | use update-hook example by Carl from Documentation/howto/ |
| 1033 | for branch policy control. |
| 1034 | </p> |
| 1035 | </li> |
| 1036 | <li> |
| 1037 | <p> |
| 1038 | alice and cindy can push into master, only bob can push into doc-update. |
| 1039 | david is the release manager and is the only person who can |
| 1040 | create and push version tags. |
| 1041 | </p> |
| 1042 | </li> |
| 1043 | </ol> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1044 | </dd> |
| 1045 | <dt> |
| 1046 | HTTP server to support dumb protocol transfer. |
| 1047 | </dt> |
| 1048 | <dd> |
| 1049 | <div class="listingblock"> |
| 1050 | <div class="content"> |
| 1051 | <pre><tt>dev$ git update-server-info <b>(1)</b> |
| 1052 | dev$ ftp user@isp.example.com <b>(2)</b> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1053 | ftp> cp -r .git /home/user/myproject.git</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1054 | </div></div> |
Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1055 | <ol> |
| 1056 | <li> |
| 1057 | <p> |
| 1058 | make sure your info/refs and objects/info/packs are up-to-date |
| 1059 | </p> |
| 1060 | </li> |
| 1061 | <li> |
| 1062 | <p> |
| 1063 | upload to public HTTP server hosted by your ISP. |
| 1064 | </p> |
| 1065 | </li> |
| 1066 | </ol> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1067 | </dd> |
| 1068 | </dl> |
| 1069 | </div> |
| 1070 | <div id="footer"> |
| 1071 | <div id="footer-text"> |
Junio C Hamano | 20f64da | 2007-04-04 18:38:30 | [diff] [blame] | 1072 | Last updated 04-Apr-2007 18:34:46 UTC |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1073 | </div> |
| 1074 | </div> |
| 1075 | </body> |
| 1076 | </html> |