-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGit - gittutorial Documentation.html
1303 lines (1263 loc) · 48.8 KB
/
Git - gittutorial Documentation.html
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
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<!-- saved from url=(0036)https://git-scm.com/docs/gittutorial -->
<html lang="en" class=" js fontface webkit chrome windows no-ie8"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<title>Git - gittutorial Documentation</title>
<link href="https://git-scm.com/favicon.ico" rel="shortcut icon" type="image/x-icon">
<link rel="alternate" href="https://git-scm.com/blog.rss" type="application/rss+xml" title="Git - Blog">
<link rel="stylesheet" media="screen" href="./Git - gittutorial Documentation_files/git-scm-c4d5b16a274fa90278203ca038fe3ad8.css">
<script type="text/javascript" async="" id="gauges-tracker" data-site-id="4f919d1df5a1f504b3000026" src="./Git - gittutorial Documentation_files/track.js.download"></script><script src="./Git - gittutorial Documentation_files/modernizr-10d8d48497292341fc1c4a63d06c6f61.js.download"></script>
<script src="./Git - gittutorial Documentation_files/modernizr-tests-0e26a9afd9c6455a99b7b4165485c366.js.download"></script>
<!--[if (gte IE 6)&(lte IE 8)]>
<script src="/javascripts/selectivizr-min.js"></script>
<![endif]-->
<script src="./Git - gittutorial Documentation_files/jsq2fql.js.download" type="text/javascript"></script>
<script>
//<![CDATA[
try{Typekit.load();}catch(e){}
//]]>
</script>
</head>
<body id="documentation">
<div class="inner">
<header>
<a href="https://git-scm.com/"><img src="./Git - gittutorial Documentation_files/[email protected]" width="110" height="46" alt="Git"></a>
<span id="tagline">--local-branching-on-the-cheap</span>
<script type="text/javascript">
var taglines = ["fast-version-control","everything-is-local","distributed-even-if-your-workflow-isnt","local-branching-on-the-cheap","distributed-is-the-new-centralized"];
var tagline = taglines[Math.floor(Math.random() * taglines.length)];
document.getElementById('tagline').innerHTML = '--' + tagline;
</script>
<form id="search" action="https://git-scm.com/search/results">
<input id="search-text" name="search" placeholder="Search entire site..." autocomplete="off" type="text">
</form>
<div id="search-results"></div>
</header>
</div> <!-- .inner -->
<div class="inner">
<div id="content-wrapper">
<aside class="sidebar">
<nav>
<ul>
<li>
<a href="https://git-scm.com/about">About</a>
</li>
<li>
<a class="active" href="https://git-scm.com/doc">Documentation</a>
<ul class="expanded">
<li>
<a href="https://git-scm.com/docs">Reference</a>
</li>
<li>
<a href="https://git-scm.com/book">Book</a>
</li>
<li>
<a href="https://git-scm.com/videos">Videos</a>
</li>
<li>
<a href="https://git-scm.com/doc/ext">External Links</a>
</li>
</ul>
</li>
<li>
<a href="https://git-scm.com/blog">Blog</a>
</li>
<li>
<a href="https://git-scm.com/downloads">Downloads</a>
<ul class="">
<li>
<a href="https://git-scm.com/downloads/guis">GUI Clients</a>
</li>
<li>
<a href="https://git-scm.com/downloads/logos">Logos</a>
</li>
</ul>
</li>
<li>
<a href="https://git-scm.com/community">Community</a>
</li>
</ul>
</nav>
</aside>
<div id="content">
<div id="reference-version">
<a class="dropdown-trigger" id="reference-topics-trigger" data-panel-id="topics-dropdown" href="https://git-scm.com/docs/gittutorial#">Topics ▾</a>
<div class="dropdown-panel right" id="topics-dropdown">
<div class="three-column">
<div class="column-left">
<h3 class="setup">Setup and Config</h3>
<ul class="unstyled">
<li><a href="https://git-scm.com/docs/git">git</a></li>
<li><a href="https://git-scm.com/docs/git-config">config</a></li>
<li><a href="https://git-scm.com/docs/git-help">help</a></li>
</ul>
<h3 class="projects">Getting and Creating Projects</h3>
<ul class="unstyled">
<li><a href="https://git-scm.com/docs/git-init">init</a></li>
<li><a href="https://git-scm.com/docs/git-clone">clone</a></li>
</ul>
<h3 class="snapshotting">Basic Snapshotting</h3>
<ul class="unstyled">
<li><a href="https://git-scm.com/docs/git-add">add</a></li>
<li><a href="https://git-scm.com/docs/git-status">status</a></li>
<li><a href="https://git-scm.com/docs/git-diff">diff</a></li>
<li><a href="https://git-scm.com/docs/git-commit">commit</a></li>
<li><a href="https://git-scm.com/docs/git-reset">reset</a></li>
<li><a href="https://git-scm.com/docs/git-rm">rm</a></li>
<li><a href="https://git-scm.com/docs/git-mv">mv</a></li>
</ul>
<h3 class="branching">Branching and Merging</h3>
<ul class="unstyled">
<li><a href="https://git-scm.com/docs/git-branch">branch</a></li>
<li><a href="https://git-scm.com/docs/git-checkout">checkout</a></li>
<li><a href="https://git-scm.com/docs/git-merge">merge</a></li>
<li><a href="https://git-scm.com/docs/git-mergetool">mergetool</a></li>
<li><a href="https://git-scm.com/docs/git-log">log</a></li>
<li><a href="https://git-scm.com/docs/git-stash">stash</a></li>
<li><a href="https://git-scm.com/docs/git-tag">tag</a></li>
</ul>
<h3 class="sharing">Sharing and Updating Projects</h3>
<ul class="unstyled">
<li><a href="https://git-scm.com/docs/git-fetch">fetch</a></li>
<li><a href="https://git-scm.com/docs/git-pull">pull</a></li>
<li><a href="https://git-scm.com/docs/git-push">push</a></li>
<li><a href="https://git-scm.com/docs/git-remote">remote</a></li>
<li><a href="https://git-scm.com/docs/git-submodule">submodule</a></li>
</ul>
</div>
<div class="column-middle">
<h3 class="inspection">Inspection and Comparison</h3>
<ul class="unstyled">
<li><a href="https://git-scm.com/docs/git-show">show</a></li>
<li><a href="https://git-scm.com/docs/git-log">log</a></li>
<li><a href="https://git-scm.com/docs/git-diff">diff</a></li>
<li><a href="https://git-scm.com/docs/git-shortlog">shortlog</a></li>
<li><a href="https://git-scm.com/docs/git-describe">describe</a></li>
</ul>
<h3 class="patching">Patching</h3>
<ul class="unstyled">
<li><a href="https://git-scm.com/docs/git-apply">apply</a></li>
<li><a href="https://git-scm.com/docs/git-cherry-pick">cherry-pick</a></li>
<li><a href="https://git-scm.com/docs/git-diff">diff</a></li>
<li><a href="https://git-scm.com/docs/git-rebase">rebase</a></li>
<li><a href="https://git-scm.com/docs/git-revert">revert</a></li>
</ul>
<h3 class="debugging">Debugging</h3>
<ul class="unstyled">
<li><a href="https://git-scm.com/docs/git-bisect">bisect</a></li>
<li><a href="https://git-scm.com/docs/git-blame">blame</a></li>
<li><a href="https://git-scm.com/docs/git-grep">grep</a></li>
</ul>
<h3 class="email">Email</h3>
<ul class="unstyled">
<li><a href="https://git-scm.com/docs/git-am">am</a></li>
<li><a href="https://git-scm.com/docs/git-apply">apply</a></li>
<li><a href="https://git-scm.com/docs/git-format-patch">format-patch</a></li>
<li><a href="https://git-scm.com/docs/git-send-email">send-email</a></li>
<li><a href="https://git-scm.com/docs/git-request-pull">request-pull</a></li>
</ul>
<h3 class="external">External Systems</h3>
<ul class="unstyled">
<li><a href="https://git-scm.com/docs/git-svn">svn</a></li>
<li><a href="https://git-scm.com/docs/git-fast-import">fast-import</a></li>
</ul>
<h3 class="server-admin">Server Admin</h3>
<ul class="unstyled">
<li><a href="https://git-scm.com/docs/git-daemon">daemon</a></li>
<li><a href="https://git-scm.com/docs/git-update-server-info">update-server-info</a></li>
</ul>
</div>
<div class="column-right">
<h3 class="guides">Guides</h3>
<ul class="unstyled">
<li><a href="https://git-scm.com/docs/gitattributes">gitattributes</a></li>
<li><a href="https://git-scm.com/docs/giteveryday">Everyday Git</a></li>
<li><a href="https://git-scm.com/docs/gitglossary">Glossary</a></li>
<li><a href="https://git-scm.com/docs/gitignore">gitignore</a></li>
<li><a href="https://git-scm.com/docs/gitmodules">gitmodules</a></li>
<li><a href="https://git-scm.com/docs/gitrevisions">Revisions</a></li>
<li><a href="https://git-scm.com/docs/gittutorial">Tutorial</a></li>
<li><a href="https://git-scm.com/docs/gitworkflows">Workflows</a></li>
</ul>
<h3 class="admin">Administration</h3>
<ul class="unstyled">
<li><a href="https://git-scm.com/docs/git-clean">clean</a></li>
<li><a href="https://git-scm.com/docs/git-gc">gc</a></li>
<li><a href="https://git-scm.com/docs/git-fsck">fsck</a></li>
<li><a href="https://git-scm.com/docs/git-reflog">reflog</a></li>
<li><a href="https://git-scm.com/docs/git-filter-branch">filter-branch</a></li>
<li><a href="https://git-scm.com/docs/git-instaweb">instaweb</a></li>
<li><a href="https://git-scm.com/docs/git-archive">archive</a></li>
<li><a href="https://git-scm.com/docs/git-bundle">bundle</a></li>
</ul>
<h3 class="plumbing">Plumbing Commands</h3>
<ul class="unstyled">
<li><a href="https://git-scm.com/docs/git-cat-file">cat-file</a></li>
<li><a href="https://git-scm.com/docs/git-check-ignore">check-ignore</a></li>
<li><a href="https://git-scm.com/docs/git-commit-tree">commit-tree</a></li>
<li><a href="https://git-scm.com/docs/git-count-objects">count-objects</a></li>
<li><a href="https://git-scm.com/docs/git-diff-index">diff-index</a></li>
<li><a href="https://git-scm.com/docs/git-for-each-ref">for-each-ref</a></li>
<li><a href="https://git-scm.com/docs/git-hash-object">hash-object</a></li>
<li><a href="https://git-scm.com/docs/git-ls-files">ls-files</a></li>
<li><a href="https://git-scm.com/docs/git-merge-base">merge-base</a></li>
<li><a href="https://git-scm.com/docs/git-read-tree">read-tree</a></li>
<li><a href="https://git-scm.com/docs/git-rev-list">rev-list</a></li>
<li><a href="https://git-scm.com/docs/git-rev-parse">rev-parse</a></li>
<li><a href="https://git-scm.com/docs/git-show-ref">show-ref</a></li>
<li><a href="https://git-scm.com/docs/git-symbolic-ref">symbolic-ref</a></li>
<li><a href="https://git-scm.com/docs/git-update-index">update-index</a></li>
<li><a href="https://git-scm.com/docs/git-update-ref">update-ref</a></li>
<li><a href="https://git-scm.com/docs/git-verify-pack">verify-pack</a></li>
<li><a href="https://git-scm.com/docs/git-write-tree">write-tree</a></li>
</ul>
</div>
</div>
</div>
<a class="dropdown-trigger" id="reference-versions-trigger" data-panel-id="previous-versions-dropdown" href="https://git-scm.com/docs/gittutorial#">Version 2.12.0 ▾</a>
<span class="light">gittutorial last updated in 2.12.0</span>
<div class="dropdown-panel left" id="previous-versions-dropdown">
<header>Changes in the <strong>gittutorial</strong> manual</header>
<ol class="reference-previous-versions">
<li>
<a href="https://git-scm.com/docs/gittutorial/2.12.0"><span class="version">2.12.0</span>
<span class="diff">
<img src="./Git - gittutorial Documentation_files/green-dot.png">
<img src="./Git - gittutorial Documentation_files/red-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
</span>
<em class="date">02/24/17</em>
</a>
</li>
<li class="no-change"><span>2.8.1 → 2.11.1 no changes</span></li>
<li>
<a href="https://git-scm.com/docs/gittutorial/2.8.0"><span class="version">2.8.0</span>
<span class="diff">
<img src="./Git - gittutorial Documentation_files/green-dot.png">
<img src="./Git - gittutorial Documentation_files/red-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
</span>
<em class="date">03/28/16</em>
</a>
</li>
<li class="no-change"><span>2.5.2 → 2.7.4 no changes</span></li>
<li>
<a href="https://git-scm.com/docs/gittutorial/2.5.1"><span class="version">2.5.1</span>
<span class="diff">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
</span>
<em class="date">08/28/15</em>
</a>
</li>
<li>
<a href="https://git-scm.com/docs/gittutorial/2.5.0"><span class="version">2.5.0</span>
<span class="diff">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
</span>
<em class="date">07/27/15</em>
</a>
</li>
<li class="no-change"><span>2.4.10 no changes</span></li>
<li>
<a href="https://git-scm.com/docs/gittutorial/2.4.9"><span class="version">2.4.9</span>
<span class="diff">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
</span>
<em class="date">09/04/15</em>
</a>
</li>
<li class="no-change"><span>2.4.1 → 2.4.8 no changes</span></li>
<li>
<a href="https://git-scm.com/docs/gittutorial/2.4.0"><span class="version">2.4.0</span>
<span class="diff">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
</span>
<em class="date">04/30/15</em>
</a>
</li>
<li>
<a href="https://git-scm.com/docs/gittutorial/2.3.9"><span class="version">2.3.9</span>
<span class="diff">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
</span>
<em class="date">09/04/15</em>
</a>
</li>
<li class="no-change"><span>2.2.1 → 2.3.8 no changes</span></li>
<li>
<a href="https://git-scm.com/docs/gittutorial/2.2.0"><span class="version">2.2.0</span>
<span class="diff">
<img src="./Git - gittutorial Documentation_files/green-dot.png">
<img src="./Git - gittutorial Documentation_files/red-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
</span>
<em class="date">11/26/14</em>
</a>
</li>
<li class="no-change"><span>1.8.2.2 → 2.1.4 no changes</span></li>
<li>
<a href="https://git-scm.com/docs/gittutorial/1.8.2.1"><span class="version">1.8.2.1</span>
<span class="diff">
<img src="./Git - gittutorial Documentation_files/green-dot.png">
<img src="./Git - gittutorial Documentation_files/red-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
<img src="./Git - gittutorial Documentation_files/grey-dot.png">
</span>
<em class="date">04/07/13</em>
</a>
</li>
<li> </li>
<!-- <li><a class="more" href="#">See more previous releases →</a></li> -->
</ol>
<footer>
<span class="light">Check your version of git by running<br></span>
<strong>$</strong>
<input type="text" class="copyable" value="git --version">
</footer>
</div>
</div>
<div id="main">
<div class="sect1">
<h2 id="_name"><a class="anchor" href="https://git-scm.com/docs/gittutorial#_name"></a>NAME</h2>
<div class="sectionbody">
<div class="paragraph">
<p>gittutorial - A tutorial introduction to Git</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_synopsis"><a class="anchor" href="https://git-scm.com/docs/gittutorial#_synopsis"></a>SYNOPSIS</h2>
<div class="sectionbody">
<div class="verseblock">
<pre class="content">git *</pre>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_description"><a class="anchor" href="https://git-scm.com/docs/gittutorial#_description"></a>DESCRIPTION</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This tutorial explains how to import a new project into Git, make
changes to it, and share changes with other developers.</p>
</div>
<div class="paragraph">
<p>If you are instead primarily interested in using Git to fetch a project,
for example, to test the latest version, you may prefer to start with
the first two chapters of <a href="https://git-scm.com/docs/user-manual.html">The Git User’s Manual</a>.</p>
</div>
<div class="paragraph">
<p>First, note that you can get documentation for a command such as
<code>git log --graph</code> with:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ man git-log</pre>
</div>
</div>
<div class="paragraph">
<p>or:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git help log</pre>
</div>
</div>
<div class="paragraph">
<p>With the latter, you can use the manual viewer of your choice; see
<a href="https://git-scm.com/docs/git-help">git-help[1]</a> for more information.</p>
</div>
<div class="paragraph">
<p>It is a good idea to introduce yourself to Git with your name and
public email address before doing any operation. The easiest
way to do so is:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git config --global user.name "Your Name Comes Here"
$ git config --global user.email [email protected]</pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_importing_a_new_project"><a class="anchor" href="https://git-scm.com/docs/gittutorial#_importing_a_new_project"></a>Importing a new project</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Assume you have a tarball project.tar.gz with your initial work. You
can place it under Git revision control as follows.</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ tar xzf project.tar.gz
$ cd project
$ git init</pre>
</div>
</div>
<div class="paragraph">
<p>Git will reply</p>
</div>
<div class="listingblock">
<div class="content">
<pre>Initialized empty Git repository in .git/</pre>
</div>
</div>
<div class="paragraph">
<p>You’ve now initialized the working directory—you may notice a new
directory created, named ".git".</p>
</div>
<div class="paragraph">
<p>Next, tell Git to take a snapshot of the contents of all files under the
current directory (note the <em>.</em>), with <em>git add</em>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git add .</pre>
</div>
</div>
<div class="paragraph">
<p>This snapshot is now stored in a temporary staging area which Git calls
the "index". You can permanently store the contents of the index in the
repository with <em>git commit</em>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git commit</pre>
</div>
</div>
<div class="paragraph">
<p>This will prompt you for a commit message. You’ve now stored the first
version of your project in Git.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_making_changes"><a class="anchor" href="https://git-scm.com/docs/gittutorial#_making_changes"></a>Making changes</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Modify some files, then add their updated contents to the index:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git add file1 file2 file3</pre>
</div>
</div>
<div class="paragraph">
<p>You are now ready to commit. You can see what is about to be committed
using <em>git diff</em> with the --cached option:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git diff --cached</pre>
</div>
</div>
<div class="paragraph">
<p>(Without --cached, <em>git diff</em> will show you any changes that
you’ve made but not yet added to the index.) You can also get a brief
summary of the situation with <em>git status</em>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git status
On branch master
Changes to be committed:
Your branch is up-to-date with 'origin/master'.
(use "git reset HEAD <file>..." to unstage)
modified: file1
modified: file2
modified: file3</pre>
</div>
</div>
<div class="paragraph">
<p>If you need to make any further adjustments, do so now, and then add any
newly modified content to the index. Finally, commit your changes with:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git commit</pre>
</div>
</div>
<div class="paragraph">
<p>This will again prompt you for a message describing the change, and then
record a new version of the project.</p>
</div>
<div class="paragraph">
<p>Alternatively, instead of running <em>git add</em> beforehand, you can use</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git commit -a</pre>
</div>
</div>
<div class="paragraph">
<p>which will automatically notice any modified (but not new) files, add
them to the index, and commit, all in one step.</p>
</div>
<div class="paragraph">
<p>A note on commit messages: Though not required, it’s a good idea to
begin the commit message with a single short (less than 50 character)
line summarizing the change, followed by a blank line and then a more
thorough description. The text up to the first blank line in a commit
message is treated as the commit title, and that title is used
throughout Git. For example, <a href="https://git-scm.com/docs/git-format-patch">git-format-patch[1]</a> turns a
commit into email, and it uses the title on the Subject line and the
rest of the commit in the body.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_git_tracks_content_not_files"><a class="anchor" href="https://git-scm.com/docs/gittutorial#_git_tracks_content_not_files"></a>Git tracks content not files</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Many revision control systems provide an <code>add</code> command that tells the
system to start tracking changes to a new file. Git’s <code>add</code> command
does something simpler and more powerful: <em>git add</em> is used both for new
and newly modified files, and in both cases it takes a snapshot of the
given files and stages that content in the index, ready for inclusion in
the next commit.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_viewing_project_history"><a class="anchor" href="https://git-scm.com/docs/gittutorial#_viewing_project_history"></a>Viewing project history</h2>
<div class="sectionbody">
<div class="paragraph">
<p>At any point you can view the history of your changes using</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git log</pre>
</div>
</div>
<div class="paragraph">
<p>If you also want to see complete diffs at each step, use</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git log -p</pre>
</div>
</div>
<div class="paragraph">
<p>Often the overview of the change is useful to get a feel of
each step</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git log --stat --summary</pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_managing_branches"><a class="anchor" href="https://git-scm.com/docs/gittutorial#_managing_branches"></a>Managing branches</h2>
<div class="sectionbody">
<div class="paragraph">
<p>A single Git repository can maintain multiple branches of
development. To create a new branch named "experimental", use</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git branch experimental</pre>
</div>
</div>
<div class="paragraph">
<p>If you now run</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git branch</pre>
</div>
</div>
<div class="paragraph">
<p>you’ll get a list of all existing branches:</p>
</div>
<div class="listingblock">
<div class="content">
<pre> experimental
* master</pre>
</div>
</div>
<div class="paragraph">
<p>The "experimental" branch is the one you just created, and the
"master" branch is a default branch that was created for you
automatically. The asterisk marks the branch you are currently on;
type</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git checkout experimental</pre>
</div>
</div>
<div class="paragraph">
<p>to switch to the experimental branch. Now edit a file, commit the
change, and switch back to the master branch:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>(edit file)
$ git commit -a
$ git checkout master</pre>
</div>
</div>
<div class="paragraph">
<p>Check that the change you made is no longer visible, since it was
made on the experimental branch and you’re back on the master branch.</p>
</div>
<div class="paragraph">
<p>You can make a different change on the master branch:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>(edit file)
$ git commit -a</pre>
</div>
</div>
<div class="paragraph">
<p>at this point the two branches have diverged, with different changes
made in each. To merge the changes made in experimental into master, run</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git merge experimental</pre>
</div>
</div>
<div class="paragraph">
<p>If the changes don’t conflict, you’re done. If there are conflicts,
markers will be left in the problematic files showing the conflict;</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git diff</pre>
</div>
</div>
<div class="paragraph">
<p>will show this. Once you’ve edited the files to resolve the
conflicts,</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git commit -a</pre>
</div>
</div>
<div class="paragraph">
<p>will commit the result of the merge. Finally,</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ gitk</pre>
</div>
</div>
<div class="paragraph">
<p>will show a nice graphical representation of the resulting history.</p>
</div>
<div class="paragraph">
<p>At this point you could delete the experimental branch with</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git branch -d experimental</pre>
</div>
</div>
<div class="paragraph">
<p>This command ensures that the changes in the experimental branch are
already in the current branch.</p>
</div>
<div class="paragraph">
<p>If you develop on a branch crazy-idea, then regret it, you can always
delete the branch with</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ git branch -D crazy-idea</pre>
</div>
</div>
<div class="paragraph">
<p>Branches are cheap and easy, so this is a good way to try something
out.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_using_git_for_collaboration"><a class="anchor" href="https://git-scm.com/docs/gittutorial#_using_git_for_collaboration"></a>Using Git for collaboration</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Suppose that Alice has started a new project with a Git repository in
/home/alice/project, and that Bob, who has a home directory on the
same machine, wants to contribute.</p>
</div>
<div class="paragraph">
<p>Bob begins with:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>bob$ git clone /home/alice/project myrepo</pre>
</div>
</div>
<div class="paragraph">
<p>This creates a new directory "myrepo" containing a clone of Alice’s
repository. The clone is on an equal footing with the original
project, possessing its own copy of the original project’s history.</p>
</div>
<div class="paragraph">
<p>Bob then makes some changes and commits them:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>(edit files)
bob$ git commit -a
(repeat as necessary)</pre>
</div>
</div>
<div class="paragraph">
<p>When he’s ready, he tells Alice to pull changes from the repository
at /home/bob/myrepo. She does this with:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>alice$ cd /home/alice/project
alice$ git pull /home/bob/myrepo master</pre>
</div>
</div>
<div class="paragraph">
<p>This merges the changes from Bob’s "master" branch into Alice’s
current branch. If Alice has made her own changes in the meantime,
then she may need to manually fix any conflicts.</p>
</div>
<div class="paragraph">
<p>The "pull" command thus performs two operations: it fetches changes
from a remote branch, then merges them into the current branch.</p>
</div>
<div class="paragraph">
<p>Note that in general, Alice would want her local changes committed before
initiating this "pull". If Bob’s work conflicts with what Alice did since
their histories forked, Alice will use her working tree and the index to
resolve conflicts, and existing local changes will interfere with the
conflict resolution process (Git will still perform the fetch but will
refuse to merge --- Alice will have to get rid of her local changes in
some way and pull again when this happens).</p>
</div>
<div class="paragraph">
<p>Alice can peek at what Bob did without merging first, using the "fetch"
command; this allows Alice to inspect what Bob did, using a special
symbol "FETCH_HEAD", in order to determine if he has anything worth
pulling, like this:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>alice$ git fetch /home/bob/myrepo master
alice$ git log -p HEAD..FETCH_HEAD</pre>
</div>
</div>
<div class="paragraph">
<p>This operation is safe even if Alice has uncommitted local changes.
The range notation "HEAD..FETCH_HEAD" means "show everything that is reachable
from the FETCH_HEAD but exclude anything that is reachable from HEAD".
Alice already knows everything that leads to her current state (HEAD),
and reviews what Bob has in his state (FETCH_HEAD) that she has not
seen with this command.</p>
</div>
<div class="paragraph">
<p>If Alice wants to visualize what Bob did since their histories forked
she can issue the following command:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ gitk HEAD..FETCH_HEAD</pre>
</div>
</div>
<div class="paragraph">
<p>This uses the same two-dot range notation we saw earlier with <em>git log</em>.</p>
</div>
<div class="paragraph">
<p>Alice may want to view what both of them did since they forked.
She can use three-dot form instead of the two-dot form:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ gitk HEAD...FETCH_HEAD</pre>
</div>
</div>
<div class="paragraph">
<p>This means "show everything that is reachable from either one, but
exclude anything that is reachable from both of them".</p>
</div>
<div class="paragraph">
<p>Please note that these range notation can be used with both gitk
and "git log".</p>
</div>
<div class="paragraph">
<p>After inspecting what Bob did, if there is nothing urgent, Alice may
decide to continue working without pulling from Bob. If Bob’s history
does have something Alice would immediately need, Alice may choose to
stash her work-in-progress first, do a "pull", and then finally unstash
her work-in-progress on top of the resulting history.</p>
</div>
<div class="paragraph">
<p>When you are working in a small closely knit group, it is not
unusual to interact with the same repository over and over
again. By defining <em>remote</em> repository shorthand, you can make
it easier:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>alice$ git remote add bob /home/bob/myrepo</pre>
</div>
</div>
<div class="paragraph">
<p>With this, Alice can perform the first part of the "pull" operation
alone using the <em>git fetch</em> command without merging them with her own
branch, using:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>alice$ git fetch bob</pre>
</div>
</div>
<div class="paragraph">
<p>Unlike the longhand form, when Alice fetches from Bob using a
remote repository shorthand set up with <em>git remote</em>, what was
fetched is stored in a remote-tracking branch, in this case
<code>bob/master</code>. So after this:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>alice$ git log -p master..bob/master</pre>
</div>
</div>
<div class="paragraph">
<p>shows a list of all the changes that Bob made since he branched from
Alice’s master branch.</p>
</div>
<div class="paragraph">
<p>After examining those changes, Alice
could merge the changes into her master branch:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>alice$ git merge bob/master</pre>
</div>
</div>
<div class="paragraph">
<p>This <code>merge</code> can also be done by <em>pulling from her own remote-tracking
branch</em>, like this:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>alice$ git pull . remotes/bob/master</pre>
</div>
</div>
<div class="paragraph">
<p>Note that git pull always merges into the current branch,
regardless of what else is given on the command line.</p>
</div>
<div class="paragraph">
<p>Later, Bob can update his repo with Alice’s latest changes using</p>
</div>
<div class="listingblock">
<div class="content">
<pre>bob$ git pull</pre>
</div>
</div>
<div class="paragraph">
<p>Note that he doesn’t need to give the path to Alice’s repository;
when Bob cloned Alice’s repository, Git stored the location of her
repository in the repository configuration, and that location is
used for pulls:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>bob$ git config --get remote.origin.url
/home/alice/project</pre>
</div>
</div>
<div class="paragraph">
<p>(The complete configuration created by <em>git clone</em> is visible using
<code>git config -l</code>, and the <a href="https://git-scm.com/docs/git-config">git-config[1]</a> man page
explains the meaning of each option.)</p>
</div>
<div class="paragraph">
<p>Git also keeps a pristine copy of Alice’s master branch under the
name "origin/master":</p>
</div>
<div class="listingblock">
<div class="content">
<pre>bob$ git branch -r
origin/master</pre>
</div>
</div>
<div class="paragraph">
<p>If Bob later decides to work from a different host, he can still
perform clones and pulls using the ssh protocol:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>bob$ git clone alice.org:/home/alice/project myrepo</pre>
</div>
</div>
<div class="paragraph">
<p>Alternatively, Git has a native protocol, or can use http;
see <a href="https://git-scm.com/docs/git-pull">git-pull[1]</a> for details.</p>
</div>
<div class="paragraph">
<p>Git can also be used in a CVS-like mode, with a central repository
that various users push changes to; see <a href="https://git-scm.com/docs/git-push">git-push[1]</a> and
<a href="https://git-scm.com/docs/gitcvs-migration">gitcvs-migration[7]</a>.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_exploring_history"><a class="anchor" href="https://git-scm.com/docs/gittutorial#_exploring_history"></a>Exploring history</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Git history is represented as a series of interrelated commits. We
have already seen that the <em>git log</em> command can list those commits.
Note that first line of each git log entry also gives a name for the