/usr/share/doc/gitmagic/html/ch01.html is in gitmagic 20160304-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta name="generator" content=
  "HTML Tidy for Linux (vers 25 March 2009), see www.w3.org">
  <meta http-equiv="Content-Type" content=
  "text/html; charset=utf-8">
  <title>Git Magic - Chapter 1. Introduction</title>
  <link rel="stylesheet" type="text/css" href="default.css">
  <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
  <link rel="home" href="index.html" title="Git Magic">
  <link rel="up" href="index.html" title="Git Magic">
  <link rel="prev" href="index.html" title="Preface">
  <link rel="next" href="ch02.html" title=
  "Chapter 2. Basic Tricks">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084"
alink="#0000FF">
    <div class="toc">
      <ul class="toc">
<li><b>Git Magic</b></li>
        <li>
          <span class="preface"><a href=
          "index.html">Preface</a></span>
          <ul>
            <li><span class="section"><a href=
            "index.html#thanks">Thanks!</a></span></li>
            <li><span class="section"><a href=
            "index.html#license">License</a></span></li>
          </ul>
        </li>
        <li>
          <span class="chapter"><a href="ch01.html">1.
          Introduction</a></span>
          <ul>
            <li><span class="section"><a href=
            "ch01.html#work_is_play">Work is Play</a></span></li>
            <li><span class="section"><a href=
            "ch01.html#version_control">Version
            Control</a></span></li>
            <li><span class="section"><a href=
            "ch01.html#distributed_control">Distributed
            Control</a></span></li>
            <li><span class="section"><a href=
            "ch01.html#a_silly_superstition">A Silly
            Superstition</a></span></li>
            <li><span class="section"><a href=
            "ch01.html#merge_conflicts">Merge
            Conflicts</a></span></li>
          </ul>
        </li>
        <li>
          <span class="chapter"><a href="ch02.html">2. Basic
          Tricks</a></span>
          <ul>
            <li><span class="section"><a href=
            "ch02.html#saving_state">Saving State</a></span></li>
            <li><span class="section"><a href=
            "ch02.html#add_delete_rename">Add, Delete,
            Rename</a></span></li>
            <li><span class="section"><a href=
            "ch02.html#advanced_undo_redo">Advanced
            Undo/Redo</a></span></li>
            <li><span class="section"><a href=
            "ch02.html#reverting">Reverting</a></span></li>
            <li><span class="section"><a href=
            "ch02.html#changelog_generation">Changelog
            Generation</a></span></li>
            <li><span class="section"><a href=
            "ch02.html#downloading_files">Downloading
            Files</a></span></li>
            <li><span class="section"><a href=
            "ch02.html#the_bleeding_edge">The Bleeding
            Edge</a></span></li>
            <li><span class="section"><a href=
            "ch02.html#instant_publishing">Instant
            Publishing</a></span></li>
            <li><span class="section"><a href=
            "ch02.html#what_have_i_done">What Have I
            Done?</a></span></li>
            <li><span class="section"><a href=
            "ch02.html#exercise">Exercise</a></span></li>
          </ul>
        </li>
        <li>
          <span class="chapter"><a href="ch03.html">3. Cloning
          Around</a></span>
          <ul>
            <li><span class="section"><a href=
            "ch03.html#sync_computers">Sync
            Computers</a></span></li>
            <li><span class="section"><a href=
            "ch03.html#classic_source_control">Classic Source
            Control</a></span></li>
            <li><span class="section"><a href=
            "ch03.html#secret_source">Secret Source</a></span></li>
            <li><span class="section"><a href=
            "ch03.html#bare_repositories">Bare
            repositories</a></span></li>
            <li><span class="section"><a href=
            "ch03.html#push_versus_pull">Push versus
            pull</a></span></li>
            <li><span class="section"><a href=
            "ch03.html#forking_a_project">Forking a
            Project</a></span></li>
            <li><span class="section"><a href=
            "ch03.html#ultimate_backups">Ultimate
            Backups</a></span></li>
            <li><span class="section"><a href=
            "ch03.html#light_speed_multitask">Light-Speed
            Multitask</a></span></li>
            <li><span class="section"><a href=
            "ch03.html#guerilla_version_control">Guerilla Version
            Control</a></span></li>
            <li><span class="section"><a href=
            "ch03.html#mercurial">Mercurial</a></span></li>
            <li><span class="section"><a href=
            "ch03.html#bazaar">Bazaar</a></span></li>
            <li><span class="section"><a href=
            "ch03.html#why_i_use_git">Why I use Git</a></span></li>
          </ul>
        </li>
        <li>
          <span class="chapter"><a href="ch04.html">4. Branch
          Wizardry</a></span>
          <ul>
            <li><span class="section"><a href=
            "ch04.html#the_boss_key">The Boss Key</a></span></li>
            <li><span class="section"><a href=
            "ch04.html#dirty_work">Dirty Work</a></span></li>
            <li><span class="section"><a href=
            "ch04.html#quick_fixes">Quick Fixes</a></span></li>
            <li><span class="section"><a href=
            "ch04.html#merging">Merging</a></span></li>
            <li><span class="section"><a href=
            "ch04.html#uninterrupted_workflow">Uninterrupted
            Workflow</a></span></li>
            <li><span class="section"><a href=
            "ch04.html#reorganizing_a_medley">Reorganizing a
            Medley</a></span></li>
            <li><span class="section"><a href=
            "ch04.html#managing_branches">Managing
            Branches</a></span></li>
            <li><span class="section"><a href=
            "ch04.html#temporary_branches">Temporary
            Branches</a></span></li>
            <li><span class="section"><a href=
            "ch04.html#work_how_you_want">Work How You
            Want</a></span></li>
          </ul>
        </li>
        <li>
          <span class="chapter"><a href="ch05.html">5. Lessons of
          History</a></span>
          <ul>
            <li><span class="section"><a href=
            "ch05.html#i_stand_corrected">I Stand
            Corrected</a></span></li>
            <li><span class="section"><a href=
            "ch05.html#and_then_some">… And Then
            Some</a></span></li>
            <li><span class="section"><a href=
            "ch05.html#local_changes_last">Local Changes
            Last</a></span></li>
            <li><span class="section"><a href=
            "ch05.html#rewriting_history">Rewriting
            History</a></span></li>
            <li><span class="section"><a href=
            "ch05.html#making_history">Making
            History</a></span></li>
            <li><span class="section"><a href=
            "ch05.html#where_did_it_all_go_wrong">Where Did It All
            Go Wrong?</a></span></li>
            <li><span class="section"><a href=
            "ch05.html#who_made_it_all_go_wrong">Who Made It All Go
            Wrong?</a></span></li>
            <li><span class="section"><a href=
            "ch05.html#personal_experience">Personal
            Experience</a></span></li>
          </ul>
        </li>
        <li>
          <span class="chapter"><a href="ch06.html">6. Multiplayer
          Git</a></span>
          <ul>
            <li><span class="section"><a href=
            "ch06.html#who_am_i">Who Am I?</a></span></li>
            <li><span class="section"><a href=
            "ch06.html#git_over_ssh_http">Git Over SSH,
            HTTP</a></span></li>
            <li><span class="section"><a href=
            "ch06.html#git_over_anything">Git Over
            Anything</a></span></li>
            <li><span class="section"><a href=
            "ch06.html#patches_the_global_currency">Patches: The
            Global Currency</a></span></li>
            <li><span class="section"><a href=
            "ch06.html#sorry_we_8217_ve_moved">Sorry, We’ve
            Moved</a></span></li>
            <li><span class="section"><a href=
            "ch06.html#remote_branches">Remote
            Branches</a></span></li>
            <li><span class="section"><a href=
            "ch06.html#multiple_remotes">Multiple
            Remotes</a></span></li>
            <li><span class="section"><a href=
            "ch06.html#my_preferences">My
            Preferences</a></span></li>
          </ul>
        </li>
        <li>
          <span class="chapter"><a href="ch07.html">7. Git
          Grandmastery</a></span>
          <ul>
            <li><span class="section"><a href=
            "ch07.html#source_releases">Source
            Releases</a></span></li>
            <li><span class="section"><a href=
            "ch07.html#commit_what_changed">Commit What
            Changed</a></span></li>
            <li><span class="section"><a href=
            "ch07.html#my_commit_is_too_big">My Commit Is Too
            Big!</a></span></li>
            <li><span class="section"><a href=
            "ch07.html#the_index_git_8217_s_staging_area">The
            Index: Git’s Staging Area</a></span></li>
            <li><span class="section"><a href=
            "ch07.html#don_8217_t_lose_your_head">Don’t Lose Your
            HEAD</a></span></li>
            <li><span class="section"><a href=
            "ch07.html#head_hunting">HEAD-hunting</a></span></li>
            <li><span class="section"><a href=
            "ch07.html#building_on_git">Building On
            Git</a></span></li>
            <li><span class="section"><a href=
            "ch07.html#daring_stunts">Daring Stunts</a></span></li>
            <li><span class="section"><a href=
            "ch07.html#preventing_bad_commits">Preventing Bad
            Commits</a></span></li>
          </ul>
        </li>
        <li>
          <span class="chapter"><a href="ch08.html">8. Secrets
          Revealed</a></span>
          <ul>
            <li><span class="section"><a href=
            "ch08.html#invisibility">Invisibility</a></span></li>
            <li><span class="section"><a href=
            "ch08.html#integrity">Integrity</a></span></li>
            <li><span class="section"><a href=
            "ch08.html#intelligence">Intelligence</a></span></li>
            <li><span class="section"><a href=
            "ch08.html#indexing">Indexing</a></span></li>
            <li><span class="section"><a href=
            "ch08.html#git_8217_s_origins">Git’s
            Origins</a></span></li>
            <li><span class="section"><a href=
            "ch08.html#the_object_database">The Object
            Database</a></span></li>
            <li><span class="section"><a href=
            "ch08.html#blobs">Blobs</a></span></li>
            <li><span class="section"><a href=
            "ch08.html#trees">Trees</a></span></li>
            <li><span class="section"><a href=
            "ch08.html#commits">Commits</a></span></li>
            <li><span class="section"><a href=
            "ch08.html#indistinguishable_from_magic">Indistinguishable
            From Magic</a></span></li>
          </ul>
        </li>
        <li>
          <span class="appendix"><a href="apa.html">A. Git
          Shortcomings</a></span>
          <ul>
            <li><span class="section"><a href=
            "apa.html#sha1_weaknesses">SHA1
            Weaknesses</a></span></li>
            <li><span class="section"><a href=
            "apa.html#microsoft_windows">Microsoft
            Windows</a></span></li>
            <li><span class="section"><a href=
            "apa.html#unrelated_files">Unrelated
            Files</a></span></li>
            <li><span class="section"><a href=
            "apa.html#who_8217_s_editing_what">Who’s Editing
            What?</a></span></li>
            <li><span class="section"><a href=
            "apa.html#file_history">File History</a></span></li>
            <li><span class="section"><a href=
            "apa.html#initial_clone">Initial Clone</a></span></li>
            <li><span class="section"><a href=
            "apa.html#volatile_projects">Volatile
            Projects</a></span></li>
            <li><span class="section"><a href=
            "apa.html#global_counter">Global
            Counter</a></span></li>
            <li><span class="section"><a href=
            "apa.html#empty_subdirectories">Empty
            Subdirectories</a></span></li>
            <li><span class="section"><a href=
            "apa.html#initial_commit">Initial
            Commit</a></span></li>
            <li><span class="section"><a href=
            "apa.html#interface_quirks">Interface
            Quirks</a></span></li>
          </ul>
        </li>
        <li><span class="appendix"><a href="apb.html">B.
        Translating This Guide</a></span></li>
      </ul>
    </div>
<div class="content">
  <div class="chapter">
    <div class="titlepage">
      <div>
        <div>
          <h1 class="title"><a id="introduction" name=
          "introduction"></a>Chapter 1. Introduction</h1>
        </div>
      </div>
    </div>
    <p>I’ll use an analogy to introduce version control. See
    <a class="ulink" href=
    "http://en.wikipedia.org/wiki/Revision_control" target=
    "_top">the Wikipedia entry on revision control</a> for a saner
    explanation.</p>
    <div class="section">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title"><a id="work_is_play" name=
            "work_is_play"></a>Work is Play</h2>
          </div>
        </div>
      </div>
      <p>I’ve played computer games almost all my life. In
      contrast, I only started using version control systems as an
      adult. I suspect I’m not alone, and comparing the two may
      make these concepts easier to explain and understand.</p>
      <p>Think of editing your code, or document, as playing a
      game. Once you’ve made a lot of progress, you’d like to save.
      To do so, you click on the <span class=
      "emphasis"><em>Save</em></span> button in your trusty
      editor.</p>
      <p>But this will overwrite the old version. It’s like those
      old school games which only had one save slot: sure you could
      save, but you could never go back to an older state. Which
      was a shame, because your previous save might have been right
      at an exceptionally fun part of the game that you’d like to
      revisit one day. Or worse still, your current save is in an
      unwinnable state, and you have to start again.</p>
    </div>
    <div class="section">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title"><a id="version_control" name=
            "version_control"></a>Version Control</h2>
          </div>
        </div>
      </div>
      <p>When editing, you can <span class="emphasis"><em>Save
      As…</em></span> a different file, or copy the file somewhere
      first before saving if you want to savour old versions. You
      can compress them too to save space. This is a primitive and
      labour-intensive form of version control. Computer games
      improved on this long ago, many of them providing multiple
      automatically timestamped save slots.</p>
      <p>Let’s make the problem slightly tougher. Say you have a
      bunch of files that go together, such as source code for a
      project, or files for a website. Now if you want to keep an
      old version you have to archive a whole directory. Keeping
      many versions around by hand is inconvenient, and quickly
      becomes expensive.</p>
      <p>With some computer games, a saved game really does consist
      of a directory full of files. These games hide this detail
      from the player and present a convenient interface to manage
      different versions of this directory.</p>
      <p>Version control systems are no different. They all have
      nice interfaces to manage a directory of stuff. You can save
      the state of the directory every so often, and you can load
      any one of the saved states later on. Unlike most computer
      games, they’re usually smart about conserving space.
      Typically, only a few files change from version to version,
      and not by much. Storing the differences instead of entire
      new copies saves room.</p>
    </div>
    <div class="section">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title"><a id="distributed_control" name=
            "distributed_control"></a>Distributed Control</h2>
          </div>
        </div>
      </div>
      <p>Now imagine a very difficult computer game. So difficult
      to finish that many experienced gamers all over the world
      decide to team up and share their saved games to try to beat
      it. Speedruns are real-life examples: players specializing in
      different levels of the same game collaborate to produce
      amazing results.</p>
      <p>How would you set up a system so they can get at each
      other’s saves easily? And upload new ones?</p>
      <p>In the old days, every project used centralized version
      control. A server somewhere held all the saved games. Nobody
      else did. Every player kept at most a few saved games on
      their machine. When a player wanted to make progress, they’d
      download the latest save from the main server, play a while,
      save and upload back to the server for everyone else to
      use.</p>
      <p>What if a player wanted to get an older saved game for
      some reason? Maybe the current saved game is in an unwinnable
      state because somebody forgot to pick up an object back in
      level three, and they want to find the latest saved game
      where the game can still be completed. Or maybe they want to
      compare two older saved games to see how much work a
      particular player did.</p>
      <p>There could be many reasons to want to see an older
      revision, but the outcome is the same. They have to ask the
      central server for that old saved game. The more saved games
      they want, the more they need to communicate.</p>
      <p>The new generation of version control systems, of which
      Git is a member, are known as distributed systems, and can be
      thought of as a generalization of centralized systems. When
      players download from the main server they get every saved
      game, not just the latest one. It’s as if they’re mirroring
      the central server.</p>
      <p>This initial cloning operation can be expensive,
      especially if there’s a long history, but it pays off in the
      long run. One immediate benefit is that when an old save is
      desired for any reason, communication with the central server
      is unnecessary.</p>
    </div>
    <div class="section">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title"><a id="a_silly_superstition" name=
            "a_silly_superstition"></a>A Silly Superstition</h2>
          </div>
        </div>
      </div>
      <p>A popular misconception is that distributed systems are
      ill-suited for projects requiring an official central
      repository. Nothing could be further from the truth.
      Photographing someone does not cause their soul to be stolen.
      Similarly, cloning the master repository does not diminish
      its importance.</p>
      <p>A good first approximation is that anything a centralized
      version control system can do, a well-designed distributed
      system can do better. Network resources are simply costlier
      than local resources. While we shall later see there are
      drawbacks to a distributed approach, one is less likely to
      make erroneous comparisons with this rule of thumb.</p>
      <p>A small project may only need a fraction of the features
      offered by such a system, but using systems that scale poorly
      for tiny projects is like using Roman numerals for
      calculations involving small numbers.</p>
      <p>Moreover, your project may grow beyond your original
      expectations. Using Git from the outset is like carrying a
      Swiss army knife even though you mostly use it to open
      bottles. On the day you desperately need a screwdriver you’ll
      be glad you have more than a plain bottle-opener.</p>
    </div>
    <div class="section">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title"><a id="merge_conflicts" name=
            "merge_conflicts"></a>Merge Conflicts</h2>
          </div>
        </div>
      </div>
      <p>For this topic, our computer game analogy becomes too
      thinly stretched. Instead, let us again consider editing a
      document.</p>
      <p>Suppose Alice inserts a line at the beginning of a file,
      and Bob appends one at the end of his copy. They both upload
      their changes. Most systems will automatically deduce a
      reasonable course of action: accept and merge their changes,
      so both Alice’s and Bob’s edits are applied.</p>
      <p>Now suppose both Alice and Bob have made distinct edits to
      the same line. Then it is impossible to proceed without human
      intervention. The second person to upload is informed of a
      <span class="emphasis"><em>merge conflict</em></span>, and
      must choose one edit over another, or revise the line
      entirely.</p>
      <p>More complex situations can arise. Version control systems
      handle the simpler cases themselves, and leave the difficult
      cases for humans. Usually their behaviour is
      configurable.</p>
    </div>
  </div>
</div>
</div><div class="footer"><a href="/~blynn/">Ben Lynn</a></div>
</body>
</html>
 |