This file is indexed.

/usr/share/doc/gitmagic/html/ch06.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
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
<!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&nbsp;6.&nbsp;Multiplayer Git</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="ch05.html" title=
  "Chapter&nbsp;5.&nbsp;Lessons of History">
  <link rel="next" href="ch07.html" title=
  "Chapter&nbsp;7.&nbsp;Git Grandmastery">
</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="multiplayer_git" name=
          "multiplayer_git"></a>Chapter&nbsp;6.&nbsp;Multiplayer
          Git</h1>
        </div>
      </div>
    </div>

    <p>Initially I used Git on a private project where I was the
    sole developer. Amongst the commands related to Git’s
    distributed nature, I needed only <span class=
    "strong"><strong>pull</strong></span> and <span class=
    "strong"><strong>clone</strong></span> so could I keep the same
    project in different places.</p>

    <p>Later I wanted to publish my code with Git, and include
    changes from contributors. I had to learn how to manage
    projects with multiple developers from all over the world.
    Fortunately, this is Git’s forte, and arguably its raison
    d'être.</p>

    <div class="section">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title"><a id="who_am_i" name=
            "who_am_i"></a>Who Am I?</h2>
          </div>
        </div>
      </div>

      <p>Every commit has an author name and email, which is shown
      by <span class="strong"><strong>git log</strong></span>. By
      default, Git uses system settings to populate these fields.
      To set them explicitly, type:</p>
      <pre class="literallayout">
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
</pre>

      <p>Omit the global flag to set these options only for the
      current repository.</p>
    </div>

    <div class="section">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title"><a id="git_over_ssh_http" name=
            "git_over_ssh_http"></a>Git Over SSH, HTTP</h2>
          </div>
        </div>
      </div>

      <p>Suppose you have SSH access to a web server, but Git is
      not installed. Though less efficient than its native
      protocol, Git can communicate over HTTP.</p>

      <p>Download, compile and install Git in your account, and
      create a repository in your web directory:</p>
      <pre class="literallayout">
$ GIT_DIR=proj.git git init
$ cd proj.git
$ git --bare update-server-info
$ cp hooks/post-update.sample hooks/post-update
</pre>

      <p>For older versions of Git, the copy command fails and you
      should run:</p>
      <pre class="literallayout">
$ chmod a+x hooks/post-update
</pre>

      <p>Now you can publish your latest edits via SSH from any
      clone:</p>
      <pre class="literallayout">
$ git push web.server:/path/to/proj.git master
</pre>

      <p>and anybody can get your project with:</p>
      <pre class="literallayout">
$ git clone http://web.server/proj.git
</pre>
    </div>

    <div class="section">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title"><a id="git_over_anything" name=
            "git_over_anything"></a>Git Over Anything</h2>
          </div>
        </div>
      </div>

      <p>Want to synchronize repositories without servers, or even
      a network connection? Need to improvise during an emergency?
      We’ve seen <a class="link" href=
      "ch05.html#makinghistory"><span class="strong"><strong>git
      fast-export</strong></span> and <span class=
      "strong"><strong>git fast-import</strong></span> can convert
      repositories to a single file and back</a>. We could shuttle
      such files back and forth to transport git repositories over
      any medium, but a more efficient tool is <span class=
      "strong"><strong>git bundle</strong></span>.</p>

      <p>The sender creates a <span class=
      "emphasis"><em>bundle</em></span>:</p>
      <pre class="literallayout">
$ git bundle create somefile HEAD
</pre>

      <p>then transports the bundle, <code class=
      "literal">somefile</code>, to the other party somehow: email,
      thumb drive, an <span class=
      "strong"><strong>xxd</strong></span> printout and an OCR
      scanner, reading bits over the phone, smoke signals, etc. The
      receiver retrieves commits from the bundle by typing:</p>
      <pre class="literallayout">
$ git pull somefile
</pre>

      <p>The receiver can even do this from an empty repository.
      Despite its size, <code class="literal">somefile</code>
      contains the entire original git repository.</p>

      <p>In larger projects, eliminate waste by bundling only
      changes the other repository lacks. For example, suppose the
      commit “1b6d…” is the most recent commit shared by both
      parties:</p>
      <pre class="literallayout">
$ git bundle create somefile HEAD ^1b6d
</pre>

      <p>If done frequently, one could easily forget which commit
      was last sent. The help page suggests using tags to solve
      this. Namely, after you send a bundle, type:</p>
      <pre class="literallayout">
$ git tag -f lastbundle HEAD
</pre>

      <p>and create new refresher bundles with:</p>
      <pre class="literallayout">
$ git bundle create newbundle HEAD ^lastbundle
</pre>
    </div>

    <div class="section">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title"><a id="patches_the_global_currency"
            name="patches_the_global_currency"></a>Patches: The
            Global Currency</h2>
          </div>
        </div>
      </div>

      <p>Patches are text representations of your changes that can
      be easily understood by computers and humans alike. This
      gives them universal appeal. You can email a patch to
      developers no matter what version control system they’re
      using. As long as your audience can read their email, they
      can see your edits. Similarly, on your side, all you require
      is an email account: there’s no need to setup an online Git
      repository.</p>

      <p>Recall from the first chapter:</p>
      <pre class="literallayout">
$ git diff 1b6d &gt; my.patch
</pre>

      <p>outputs a patch which can be pasted into an email for
      discussion. In a Git repository, type:</p>
      <pre class="literallayout">
$ git apply &lt; my.patch
</pre>

      <p>to apply the patch.</p>

      <p>In more formal settings, when author names and perhaps
      signatures should be recorded, generate the corresponding
      patches past a certain point by typing:</p>
      <pre class="literallayout">
$ git format-patch 1b6d
</pre>

      <p>The resulting files can be given to <span class=
      "strong"><strong>git-send-email</strong></span>, or sent by
      hand. You can also specify a range of commits:</p>
      <pre class="literallayout">
$ git format-patch 1b6d..HEAD^^
</pre>

      <p>On the receiving end, save an email to a file, then
      type:</p>
      <pre class="literallayout">
$ git am &lt; email.txt
</pre>

      <p>This applies the incoming patch and also creates a commit,
      including information such as the author.</p>

      <p>With a browser email client, you may need to click a
      button to see the email in its raw original form before
      saving the patch to a file.</p>

      <p>There are slight differences for mbox-based email clients,
      but if you use one of these, you’re probably the sort of
      person who can figure them out easily without reading
      tutorials!</p>
    </div>

    <div class="section">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title"><a id="sorry_we_8217_ve_moved" name=
            "sorry_we_8217_ve_moved"></a>Sorry, We’ve Moved</h2>
          </div>
        </div>
      </div>

      <p>After cloning a repository, running <span class=
      "strong"><strong>git push</strong></span> or <span class=
      "strong"><strong>git pull</strong></span> will automatically
      push to or pull from the original URL. How does Git do this?
      The secret lies in config options created with the clone.
      Let’s take a peek:</p>
      <pre class="literallayout">
$ git config --list
</pre>

      <p>The <code class="literal">remote.origin.url</code> option
      controls the source URL; “origin” is a nickname given to the
      source repository. As with the “master” branch convention, we
      may change or delete this nickname but there is usually no
      reason for doing so.</p>

      <p>If the original repository moves, we can update the URL
      via:</p>
      <pre class="literallayout">
$ git config remote.origin.url git://new.url/proj.git
</pre>

      <p>The <code class="literal">branch.master.merge</code>
      option specifies the default remote branch in a <span class=
      "strong"><strong>git pull</strong></span>. During the initial
      clone, it is set to the current branch of the source
      repository, so even if the HEAD of the source repository
      subsequently moves to a different branch, a later pull will
      faithfully follow the original branch.</p>

      <p>This option only applies to the repository we first cloned
      from, which is recorded in the option <code class=
      "literal">branch.master.remote</code>. If we pull in from
      other repositories we must explicitly state which branch we
      want:</p>
      <pre class="literallayout">
$ git pull git://example.com/other.git master
</pre>

      <p>The above explains why some of our earlier push and pull
      examples had no arguments.</p>
    </div>

    <div class="section">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title"><a id="remote_branches" name=
            "remote_branches"></a>Remote Branches</h2>
          </div>
        </div>
      </div>

      <p>When you clone a repository, you also clone all its
      branches. You may not have noticed this because Git hides
      them away: you must ask for them specifically. This prevents
      branches in the remote repository from interfering with your
      branches, and also makes Git easier for beginners.</p>

      <p>List the remote branches with:</p>
      <pre class="literallayout">
$ git branch -r
</pre>

      <p>You should see something like:</p>
      <pre class="literallayout">
origin/HEAD
origin/master
origin/experimental
</pre>

      <p>These represent branches and the HEAD of the remote
      repository, and can be used in regular Git commands. For
      example, suppose you have made many commits, and wish to
      compare against the last fetched version. You could search
      through the logs for the appropriate SHA1 hash, but it’s much
      easier to type:</p>
      <pre class="literallayout">
$ git diff origin/HEAD
</pre>

      <p>Or you can see what the “experimental” branch has been up
      to:</p>
      <pre class="literallayout">
$ git log origin/experimental
</pre>
    </div>

    <div class="section">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title"><a id="multiple_remotes" name=
            "multiple_remotes"></a>Multiple Remotes</h2>
          </div>
        </div>
      </div>

      <p>Suppose two other developers are working on our project,
      and we want to keep tabs on both. We can follow more than one
      repository at a time with:</p>
      <pre class="literallayout">
$ git remote add other git://example.com/some_repo.git
$ git pull other some_branch
</pre>

      <p>Now we have merged in a branch from the second repository,
      and we have easy access to all branches of all
      repositories:</p>
      <pre class="literallayout">
$ git diff origin/experimental^ other/some_branch~5
</pre>

      <p>But what if we just want to compare their changes without
      affecting our own work? In other words, we want to examine
      their branches without having their changes invade our
      working directory. Then rather than pull, run:</p>
      <pre class="literallayout">
$ git fetch        # Fetch from origin, the default.
$ git fetch other  # Fetch from the second programmer.
</pre>

      <p>This just fetches histories. Although the working
      directory remains untouched, we can refer to any branch of
      any repository in a Git command because we now possess a
      local copy.</p>

      <p>Recall that behind the scenes, a pull is simply a
      <span class="strong"><strong>fetch</strong></span> then
      <span class="strong"><strong>merge</strong></span>. Usually
      we <span class="strong"><strong>pull</strong></span> because
      we want to merge the latest commit after a fetch; this
      situation is a notable exception.</p>

      <p>See <span class="strong"><strong>git help
      remote</strong></span> for how to remove remote repositories,
      ignore certain branches, and more.</p>
    </div>

    <div class="section">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title"><a id="my_preferences" name=
            "my_preferences"></a>My Preferences</h2>
          </div>
        </div>
      </div>

      <p>For my projects, I like contributors to prepare
      repositories from which I can pull. Some Git hosting services
      let you host your own fork of a project with the click of a
      button.</p>

      <p>After I fetch a tree, I run Git commands to navigate and
      examine the changes, which ideally are well-organized and
      well-described. I merge my own changes, and perhaps make
      further edits. Once satisfied, I push to the main
      repository.</p>

      <p>Though I infrequently receive contributions, I believe
      this approach scales well. See <a class="ulink" href=
      "http://torvalds-family.blogspot.com/2009/06/happiness-is-warm-scm.html"
      target="_top">this blog post by Linus Torvalds</a>.</p>

      <p>Staying in the Git world is slightly more convenient than
      patch files, as it saves me from converting them to Git
      commits. Furthermore, Git handles details such as recording
      the author’s name and email address, as well as the time and
      date, and asks the author to describe their own change.</p>
    </div>
  </div>
</div>
</div><div class="footer"><a href="/~blynn/">Ben Lynn</a></div>
</body>
</html>