-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitExplained.html
More file actions
1726 lines (1552 loc) · 77.3 KB
/
gitExplained.html
File metadata and controls
1726 lines (1552 loc) · 77.3 KB
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
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2019-07-16 Tue 11:52 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Git Explained</title>
<meta name="generator" content="Org mode" />
<meta name="author" content="Hoyoul Park" />
<meta name="description" content="Org-HTML export made simple."
/>
<meta name="keywords" content="org-mode, export, html, theme, style, css, js, bigblow" />
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #ccc;
box-shadow: 3px 3px 3px #eee;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
/* Languages per Org manual */
pre.src-asymptote:before { content: 'Asymptote'; }
pre.src-awk:before { content: 'Awk'; }
pre.src-C:before { content: 'C'; }
/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before { content: 'Clojure'; }
pre.src-css:before { content: 'CSS'; }
pre.src-D:before { content: 'D'; }
pre.src-ditaa:before { content: 'ditaa'; }
pre.src-dot:before { content: 'Graphviz'; }
pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-fortran:before { content: 'Fortran'; }
pre.src-gnuplot:before { content: 'gnuplot'; }
pre.src-haskell:before { content: 'Haskell'; }
pre.src-hledger:before { content: 'hledger'; }
pre.src-java:before { content: 'Java'; }
pre.src-js:before { content: 'Javascript'; }
pre.src-latex:before { content: 'LaTeX'; }
pre.src-ledger:before { content: 'Ledger'; }
pre.src-lisp:before { content: 'Lisp'; }
pre.src-lilypond:before { content: 'Lilypond'; }
pre.src-lua:before { content: 'Lua'; }
pre.src-matlab:before { content: 'MATLAB'; }
pre.src-mscgen:before { content: 'Mscgen'; }
pre.src-ocaml:before { content: 'Objective Caml'; }
pre.src-octave:before { content: 'Octave'; }
pre.src-org:before { content: 'Org mode'; }
pre.src-oz:before { content: 'OZ'; }
pre.src-plantuml:before { content: 'Plantuml'; }
pre.src-processing:before { content: 'Processing.js'; }
pre.src-python:before { content: 'Python'; }
pre.src-R:before { content: 'R'; }
pre.src-ruby:before { content: 'Ruby'; }
pre.src-sass:before { content: 'Sass'; }
pre.src-scheme:before { content: 'Scheme'; }
pre.src-screen:before { content: 'Gnu Screen'; }
pre.src-sed:before { content: 'Sed'; }
pre.src-sh:before { content: 'shell'; }
pre.src-sql:before { content: 'SQL'; }
pre.src-sqlite:before { content: 'SQLite'; }
/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before { content: 'Forth'; }
pre.src-io:before { content: 'IO'; }
pre.src-J:before { content: 'J'; }
pre.src-makefile:before { content: 'Makefile'; }
pre.src-maxima:before { content: 'Maxima'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-picolisp:before { content: 'Pico Lisp'; }
pre.src-scala:before { content: 'Scala'; }
pre.src-shell:before { content: 'Shell Script'; }
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before { content: 'C++'; }
pre.src-abc:before { content: 'ABC'; }
pre.src-coq:before { content: 'Coq'; }
pre.src-groovy:before { content: 'Groovy'; }
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before { content: 'bash'; }
pre.src-csh:before { content: 'csh'; }
pre.src-ash:before { content: 'ash'; }
pre.src-dash:before { content: 'dash'; }
pre.src-ksh:before { content: 'ksh'; }
pre.src-mksh:before { content: 'mksh'; }
pre.src-posh:before { content: 'posh'; }
/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before { content: 'Ada'; }
pre.src-asm:before { content: 'Assembler'; }
pre.src-caml:before { content: 'Caml'; }
pre.src-delphi:before { content: 'Delphi'; }
pre.src-html:before { content: 'HTML'; }
pre.src-idl:before { content: 'IDL'; }
pre.src-mercury:before { content: 'Mercury'; }
pre.src-metapost:before { content: 'MetaPost'; }
pre.src-modula-2:before { content: 'Modula-2'; }
pre.src-pascal:before { content: 'Pascal'; }
pre.src-ps:before { content: 'PostScript'; }
pre.src-prolog:before { content: 'Prolog'; }
pre.src-simula:before { content: 'Simula'; }
pre.src-tcl:before { content: 'tcl'; }
pre.src-tex:before { content: 'TeX'; }
pre.src-plain-tex:before { content: 'Plain TeX'; }
pre.src-verilog:before { content: 'Verilog'; }
pre.src-vhdl:before { content: 'VHDL'; }
pre.src-xml:before { content: 'XML'; }
pre.src-nxml:before { content: 'XML'; }
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
.org-svg { width: 90%; }
/*]]>*/-->
</style>
<link rel="stylesheet" type="text/css" href="/Users/frege/.emacs.d/presentation/readtheorg/styles/readtheorg/css/htmlize.css"/>
<link rel="stylesheet" type="text/css" href="/Users/frege/.emacs.d/presentation/readtheorg/styles/readtheorg/css/readtheorg.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/Users/frege/.emacs.d/presentation/readtheorg/styles/lib/js/jquery.stickytableheaders.min.js"></script>
<script type="text/javascript" src="/Users/frege/.emacs.d/presentation/readtheorg/styles/readtheorg/js/readtheorg.js"></script>
<script type="text/javascript">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012-2018 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
</script>
</head>
<body>
<div id="content">
<h1 class="title">Git Explained</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#org8ab5084">1. Git Explained</a>
<ul>
<li><a href="#org13d70a9">1.1. Git Introduction</a></li>
<li><a href="#orgcff3bd1">1.2. Git Drill(1단계)</a>
<ul>
<li><a href="#org4be2936">git 설치(brew)</a></li>
<li><a href="#orgb4ab256">git init, git clone</a></li>
<li><a href="#orgec0ec5d">git configure</a></li>
<li><a href="#org6ce4409">git ignore</a></li>
<li><a href="#orgdf87e85">linked list</a></li>
</ul>
</li>
<li><a href="#org6965b41">1.3. git drill(2단계)</a>
<ul>
<li><a href="#org5f1ebbd">원하는 파일로 commit 만들기.</a></li>
<li><a href="#org9c9a2ab">commit 만들 때 유의할 점(2) - unstage하는 법</a></li>
<li><a href="#org2fce357">commit 만들 때 유의할 점(3) - commit취소</a></li>
<li><a href="#orga78a45b">summary</a></li>
</ul>
</li>
<li><a href="#org6e9be86">1.4. git drill3</a>
<ul>
<li><a href="#org0bafc84">Linked list 설명</a></li>
<li><a href="#orgb9b534b">변형 linked list</a></li>
<li><a href="#org8dd7201">변형 Linked list의 고찰</a></li>
<li><a href="#orgdd6e91c">git data structure vs 변형 linked list</a></li>
<li><a href="#org0d7924b">git의 용어</a></li>
</ul>
</li>
<li><a href="#org91dfe2b">1.5. git drill4</a>
<ul>
<li><a href="#org4b52b0b">흔한 질문</a></li>
<li><a href="#org75b0e83">git commit</a></li>
<li><a href="#org950e0ef">git commit –amend</a></li>
<li><a href="#orgcc86f95">git branch</a></li>
<li><a href="#org0f20844">git remote</a></li>
<li><a href="#orgf511a5e">git clone</a></li>
<li><a href="#org389a94b">git checkout [head 이동명령어]</a></li>
<li><a href="#org0f74a94">git log</a></li>
<li><a href="#orgd397a16">git reset [branch 이동]</a></li>
<li><a href="#org281d7c0">git merge</a>
<ul>
<li><a href="#org1296195">2 way merge</a></li>
<li><a href="#org0f29969">3 way merge</a></li>
<li><a href="#orgd57ce0b">summary</a></li>
</ul>
</li>
<li><a href="#org93fb677">git rebase</a>
<ul>
<li><a href="#orga594ffc">summary</a></li>
</ul>
</li>
<li><a href="#orgeb677d7">git push</a></li>
<li><a href="#org5a2195b">git pull</a></li>
<li><a href="#orgd4929d9">git reflog</a></li>
<li><a href="#org76b9bf7">git tag</a></li>
</ul>
</li>
<li><a href="#orgd71bbdc">1.6. git drill5</a>
<ul>
<li><a href="#org9a833b4">git repository</a></li>
<li><a href="#orgd089d6c">git 원격저장소와 관련한 용어들</a></li>
<li><a href="#org7f7724e"><b>1. Upstream, Downstream</b></a></li>
<li><a href="#org901cf4b"><b>2. remote branch,tracking branch,local branch</b></a>
<ul>
<li><a href="#orgb1978b0">git clone의 경우</a></li>
<li><a href="#org9eef653">git fetch의 경우</a></li>
<li><a href="#orgb5a3d6b">설명</a></li>
<li><a href="#org6dcaf1a">tracking branch</a></li>
</ul>
</li>
<li><a href="#org47dab19">git clone</a></li>
<li><a href="#org457a4b1">git fetch</a></li>
<li><a href="#orgee07a02">git pull</a></li>
<li><a href="#orgfdc6a9c">git push</a></li>
</ul>
</li>
<li><a href="#org0986aec">1.7. git drill6</a>
<ul>
<li><a href="#org9379062">git을 왜 사용하는가?</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-org8ab5084" class="outline-2">
<h2 id="org8ab5084"><span class="section-number-2">1</span> Git Explained</h2>
<div class="outline-text-2" id="text-1">
</div>
<div id="outline-container-org13d70a9" class="outline-3">
<h3 id="org13d70a9"><span class="section-number-3">1.1</span> Git Introduction</h3>
<div class="outline-text-3" id="text-1-1">
<div class="attention">
<p>
Git은 Version Controll System이다. *Git은 commit이라는 자료구조를 linked list로 연결*하기 때문에
linked list를 안다면 혹은 구현할 수 있다면, git을 이해하는 건 쉽다. linked list를 기반으로 git을
크게 4단계로 나누어서 설명할 것이다. 1단계는 git을 사용하기 위한 설치과정 및 linked list소개,
2단계는 local system에서 git의 사용, 3단계는 remote system에서 git의 사용, 4단계는 work
flow다. 부록으로 git 내부 명령어를 설명할 수도 있다. 1단계는 어디가도 있는 내용이라서 그냥
가볍게 읽고 넘어가면 된다.
</p>
</div>
</div>
</div>
<div id="outline-container-orgcff3bd1" class="outline-3">
<h3 id="orgcff3bd1"><span class="section-number-3">1.2</span> Git Drill(1단계)</h3>
<div class="outline-text-3" id="text-1-2">
<div class="attention">
<p>
1단계는 별다른게 없다. 그냥 대충 읽고 넘어가면 된다.
</p>
<p class="verse">
. git 설치 : system에 git program설치<br />
. git init : .git(repository)을 만든다.<br />
. git clone : .git(repository) 폴더를 가져온다.<br />
. git configure : git을 설정한다. commit에 자신의 정보를 넣기위해서 필요.<br />
. git ignore: git에서 처리하지 않을 파일을 기록<br />
. git의 원리: linked list<br />
</p>
</div>
</div>
<div id="outline-container-org4be2936" class="outline-4">
<h4 id="org4be2936">git 설치(brew)</h4>
<div class="outline-text-4" id="text-org4be2936">
<div class="note">
<pre class="example">
brew install git
</pre>
<p>
git을 system에 설치, 간단히 brew로 설치
</p>
</div>
</div>
</div>
<div id="outline-container-orgb4ab256" class="outline-4">
<h4 id="orgb4ab256">git init, git clone</h4>
<div class="outline-text-4" id="text-orgb4ab256">
<div class="note">
<pre class="example">
git init
git clone URL
</pre>
<p>
git init으로 현재 폴더안에.git(repository)이란 폴더를 만든다. 처음에는 commit도 없고, branch도
없다. git clone URL에서 다른곳에 있는 .git폴더를 가져오는 것이다. git clone은 remote와 관련이
있기 때문에 3단계에서도 설명을 할 것이다.
</p>
</div>
</div>
</div>
<div id="outline-container-orgec0ec5d" class="outline-4">
<h4 id="orgec0ec5d">git configure</h4>
<div class="outline-text-4" id="text-orgec0ec5d">
<div class="note">
<pre class="example">
git config --global user.name "[name]"
git config --global user.email "[name]"
</pre>
<p>
이제 저장할 공간도 확보했기 때문에 저장 하면 된다. 그런데, 좀 해주어야 할게 있다. 저장은
commit이란 형태로 저장되는데, 여기에는 어떤 사용자가 저장했는지, 언제 했는지 같은 meta data가
들어간다. 그 meta data를 설정해야 한다. 사용자 이름,email주소를 적어주면 된다.
</p>
</div>
</div>
</div>
<div id="outline-container-org6ce4409" class="outline-4">
<h4 id="org6ce4409">git ignore</h4>
<div class="outline-text-4" id="text-org6ce4409">
<div class="note">
<p>
편집기에서 .gitignore이라는 파일을 열고 다음과 같은 내용을 쓴다.
</p>
<pre class="example">
*.log
</pre>
<p>
.gitigonre파일에서 특정 파일을 commit에 포함시키지 않는다. commit을 지금 몰라도 나중에는 알게 된다.
배제할 파일 목록은 다음을 참고하면 된다.
<a href="https://gitignore.io/">https://gitignore.io/</a>
</p>
</div>
</div>
</div>
<div id="outline-container-orgdf87e85" class="outline-4">
<h4 id="orgdf87e85">linked list</h4>
<div class="outline-text-4" id="text-orgdf87e85">
<div class="attention">
<p>
git은 commit이라는 형태로 version을 관리한다. commit은 snapshot이라고도 부르는데, 찰나의
사진이라고 번역할 수도 있다. 현재 folder에 .git이 있다면 현재 폴더의 순간적인 상태를 사진으로
찍어서, 즉 snapshot을 .git폴더에 commit이란 형태로 저장한다고 보면 된다. commit은 linked list를
사용해서 저장한다. 그냥 배열을 사용해서 무턱대고 집어넣는게 아니다. 배열은 공간의 크기가 정해져
있지만, linked list는 동적이다. commit들이 link로 연결되어 있는 것이다. 새로운 commit이 오면 기존의
연결된 commit과 연결되는 것이다.
</p>
</div>
</div>
</div>
</div>
<div id="outline-container-org6965b41" class="outline-3">
<h3 id="org6965b41"><span class="section-number-3">1.3</span> git drill(2단계)</h3>
<div class="outline-text-3" id="text-1-3">
</div>
<div id="outline-container-org5f1ebbd" class="outline-4">
<h4 id="org5f1ebbd">원하는 파일로 commit 만들기.</h4>
<div class="outline-text-4" id="text-org5f1ebbd">
<div class="attention">
<p>
git은 저장시스템(repository)라고 했다. 무엇을 저장하는가? 우리가 원하는 파일을 commit의 형태로
repository에 저장한다. 그러면, 원하는 파일은 어디에 있는가? working directory라는 폴더에
있다. 그러면,repository는 어디에 있는가? working directory안에 .git이라는 폴더에 있다.
</p>
<p>
우리는 working directory의 폴더와 파일중에 commit할 것을 선택할 것이다. 선택하는 것들은 .git의
index란 파일에 기록될 것이다. 그것을 staging area라고 부르기도 한다. 여튼 우리는 선택을 해야 한다.
</p>
<p>
선택할 수 있게 git이라는 program은 git add라는 명령어를 제공한다. git add로 우린 하나 하나 원하는
파일을 선택해서 stage에 올린다. 하나 하나 선택하는 건 힘들수 있다. 왜냐면, 프로그램을 하나 짜더라도
너무나 많은 파일이 사용되고, 협업을 하게 되면 파일의 수가 많아지는건 너무나 당연하다. 그래서 보통은
git add ./* 로 전체를 올린다. 이렇게 stage에 올린 후에 git commit -m "message"를 입력하면
commit이란 형태로 저장된다. 앞으로 나오게 될 말이기도 하지만, 최초의 commit이 만들어지면, 그 때
master라는 branch도 같이 만들어 진다. Head는 이미 master를 가리키도록 HEAD라는 file에 기술되어
있다. 이런 세부적인 과정이 외우기 힘들면, commit이 만들어져야 head와 master라는 branch도
생겨난다고 이해해도 상관없다.
</p>
<pre class="example">
git add ./*
git commit -m "message"
</pre>
<p>
그림으로 보면 다음과 같다.
</p>
<div id="orge6924bb" class="figure">
<p><img src="./img/commit.png" alt="commit.png" />
</p>
<p><span class="figure-number">Figure 1: </span>commit</p>
</div>
</div>
</div>
</div>
<div id="outline-container-org9c9a2ab" class="outline-4">
<h4 id="org9c9a2ab">commit 만들 때 유의할 점(2) - unstage하는 법</h4>
<div class="outline-text-4" id="text-org9c9a2ab">
<div class="attention">
<pre class="example">
git reset HEAD [file]
</pre>
<p>
stage에 올려진 파일을 stage에서 내릴때 사용한다.
</p>
</div>
</div>
</div>
<div id="outline-container-org2fce357" class="outline-4">
<h4 id="org2fce357">commit 만들 때 유의할 점(3) - commit취소</h4>
<div class="outline-text-4" id="text-org2fce357">
<div class="attention">
<p>
commit을 만들었는데, 잘못 만들었다. 이럴 때도 git reset을 사용한다.
</p>
<pre class="example">
git reset HEAD^(이전 commit으로 되돌린다.)
</pre>
</div>
</div>
</div>
<div id="outline-container-orga78a45b" class="outline-4">
<h4 id="orga78a45b">summary</h4>
<div class="outline-text-4" id="text-orga78a45b">
<div class="note">
<div id="orgdf27828" class="figure">
<p><img src="./img/makecommit.png" alt="makecommit.png" />
</p>
<p><span class="figure-number">Figure 2: </span>git commit과정</p>
</div>
</div>
</div>
</div>
</div>
<div id="outline-container-org6e9be86" class="outline-3">
<h3 id="org6e9be86"><span class="section-number-3">1.4</span> git drill3</h3>
<div class="outline-text-3" id="text-1-4">
<p>
말하는 점 조직이란게 이런것이다. 새로운 조직원은 말단 조직원을 통해서만 들어올 수 있고, 그 윗선은
알수가 없다.
</p>
<p>
또 다른 예로, 노래테이프도 linked list로 볼 수 있다.
</p>
<div class="attention">
<p>
array나 linked list나 원하는 자료를 찾을려면, 하나하나 다 살펴봐야 하는건 동일하다. 다만, array는
data가 없어도 살펴본다. 또한 array에서는 중간의 data를 살펴보는데, 어려음이 없다. 그런데 linked
list는 중간의 data를 알려면, 이전의 data를 거치지 않고는 알 수 없다. 노래테이프도 그렇다. 생각을
해보자. 보물찾기를 해서 보물을 찾았는데, 보물에 다른 곳으로 가라고 적혀 있다면, 그곳에서 또
다른곳으로 가라고 적혀있는 것처럼, 원하는 것을 찾기위해선, 계속 찾아가야 하는 것이다.
</p>
</div>
<p>
#+end<sub>note</sub>
</p>
</div>
<div id="outline-container-org0bafc84" class="outline-4">
<h4 id="org0bafc84">Linked list 설명</h4>
<div class="outline-text-4" id="text-org0bafc84">
<div class="attention">
<p>
git은 단방향 list를 사용한다. list는 처음에 Head만 있다. HEAD를 통해서 data를 담고 있는 Node가 연결된다.
이 과정을 그림으로 남긴다.
</p>
</div>
<div class="note">
<div id="orgf2820d6" class="figure">
<p><img src="./img/linkedlist.png" alt="linkedlist.png" />
</p>
<p><span class="figure-number">Figure 3: </span>linked list</p>
</div>
</div>
<div class="attention">
<p>
linked list는 자료구조다. 자료구조는 data를 추가하거나, 중간에 삽입하거나, 삭제하거나, 갱신하는
여러 동작을 수행할 수 있어야 한다. 그것이 data structure를 사용하는 이유이고, 목적이기
때문이다. Linked list의 그런 조작에서 HEAD의 복사본이 사용된다. HEAD는 항상 data가 들어가는
입구역할을 하고, 중간에 노드를 삭제하거나, 삽입,갱신, 이 모든것은 *HEAD의 복제본*을 사용한다.
</p>
</div>
</div>
</div>
<div id="outline-container-orgb9b534b" class="outline-4">
<h4 id="orgb9b534b">변형 linked list</h4>
<div class="outline-text-4" id="text-orgb9b534b">
<div class="attention">
<p>
위에서 보면 linked list가 단방향을 가리키는 것을 볼 수 있다. Node의 삽입은 HEAD를 통해서만, 삽입되고,
마치 line과 같이 보인다. 만일 우리가 여기에 HEAD를 추가한다면 어떻게 될까?
</p>
</div>
<div class="note">
<div id="orgf80ae3f" class="figure">
<p><img src="./img/newlist1.png" alt="newlist1.png" />
</p>
<p><span class="figure-number">Figure 4: </span>new head list</p>
</div>
</div>
<div class="attention">
<p>
HEAD를 추가하면 문제가 생긴다. Node를 삽입할 때, 어떤 HEAD를 사용해야 하는가? 이런 문제가 생긴다.
이런 문제를 해결하기 위해서 변수 하나를 더 추가한다. 어떤 HEAD를 선택할 지를 결정하는 변수다.
</p>
</div>
<div class="note">
<div id="org3a3c270" class="figure">
<p><img src="./img/newlist2.png" alt="newlist2.png" />
</p>
<p><span class="figure-number">Figure 5: </span>new head</p>
</div>
</div>
<div class="note">
<p>
최종 결과는 다음과 같은 모습이 된다.
</p>
<div id="org0288864" class="figure">
<p><img src="./img/list_sum1.png" alt="list_sum1.png" />
</p>
<p><span class="figure-number">Figure 6: </span>summary1</p>
</div>
<div id="org62091a4" class="figure">
<p><img src="./img/list_sum2.png" alt="list_sum2.png" />
</p>
<p><span class="figure-number">Figure 7: </span>summary2</p>
</div>
<div id="org50f8651" class="figure">
<p><img src="./img/list_sum3.png" alt="list_sum3.png" />
</p>
<p><span class="figure-number">Figure 8: </span>summary3</p>
</div>
</div>
</div>
</div>
<div id="outline-container-org8dd7201" class="outline-4">
<h4 id="org8dd7201">변형 Linked list의 고찰</h4>
<div class="outline-text-4" id="text-org8dd7201">
<div class="attention">
<p>
우선 array란 자료구조는 고정된 size를 갖기 때문에 자료를 저장할 구조로는 적합하지 않다. 어느 정도의
data가 그 공간에 삽입될지 예측할 수 없기 때문에 computer science에서는 linked list가 자료를 저장하는
아주 기본적인 구조다. 만일 무언가 자료를 넣어야 한다면 대부분 linked list를 생각해봐야 한다. linked
list를 변형한 구조를 보여줬는데, 그 구조를 간단히 요약하면 다음과 같다. 기존의 linked list에 head만
붙이면 여러개의 list가 만들어짐을 볼 수 있었다. 그리고 Head라는게 Node삽입의 입구와 같기 때문에,
어떤 list에 삽입할 것인지는 HEAD를 정해줘야 한다. 그 HEAD를 정해주는 또다른 HEAD가 필요하다. 이 변형된 구조가
git이 가진 data structure다.
</p>
</div>
</div>
</div>
<div id="outline-container-orgdd6e91c" class="outline-4">
<h4 id="orgdd6e91c">git data structure vs 변형 linked list</h4>
<div class="outline-text-4" id="text-orgdd6e91c">
<div class="attention">
<p>
변형된 linked list를 git은 사용한다. 그런데 약간 차이가 있다. linked list라는 data structure는
기본적으로 자료를 저장하고, 찾고, 찾은 data를 수정하거나, 삭제, 추가에 대한 연산이 존재한다. 왜냐? 그럴려고
data structure를 사용하기 때문이다. 그런데 git에서는 그런 operation을 명확하게 지원하지 않는다. 지원하지
않는 이유는 한번 만들어진 Node를 수정이나 삭제 추가를 하게 되면 문제가 생기기 때문이다.
</p>
<p>
우선 git을 만든 목적을 생각해 보자. 우리는 git을 단순히 data를 저장하기 위한 목적으로 linked list를
사용한게 아니다. git의 목적중 하나는 협업이다. 각각의 사용자들이 있고, 각각의 사용자들은 변형된 linked list에서
하나의 line을 갖게 된다. 각각의 line에서 무수한 수정이 발생되면, 동기화의 문제가 생긴다. Head에서 새로운 data를
추가하는 것은 문제가 되지 않지만, 어떤 line의 중간의 data(Node)를 내가 삭제했다. 그런데 삭제되기전에
Node를 받은 사람이 그것을 수정해서 다시 서버에 올렸다고 하자. 나는 그 Node를 삭제한후 서버에 접속하지 않고
그것과 관련된 기능을 모두 삭제했는데, 다시 접속하니 이상한 파일들이 엉켜있다면? 문제가 되지 않을까? 그 git을 사용하는
사람이 1-2명이 아닌 100명,200명이 사용한다면?
</p>
<p>
git에서 history는 중요하다. 그것들이 여러사람에게 공유되고 동기화의 문제로 history의 중간 버전을 수정하는것은
상당히 위험한 행동이다.
</p>
</div>
</div>
</div>
<div id="outline-container-org0d7924b" class="outline-4">
<h4 id="org0d7924b">git의 용어</h4>
<div class="outline-text-4" id="text-org0d7924b">
<div class="note">
<p>
git은 변형 linked list를 사용한다고 했다. linked list에서 사용하는 term과 git에서 사용하는 term이 다르기 때문에 정리한다.
</p>
<div id="org4017742" class="figure">
<p><img src="./img/gitdrill3.png" alt="gitdrill3.png" />
</p>
<p><span class="figure-number">Figure 9: </span>git term</p>
</div>
<p>
commit을 만들면 이것을 list에 삽입을 해야 하는데, list에서 삽입은 HEAD가 Node를 가리키는 방식이다. Git에서 HEAD는 branch를 선택하는
용어로 쓰인다. 그리고 Branch가 list에서 HEAD에 대응되는 용어다. 즉 branch가 새로운 commit을 가리키면서 삽입이 되기 때문에 Branch는
항상 최신(recently new) commit을 가리키고 있다고 보면 된다.
</p>
</div>
</div>
</div>
</div>
<div id="outline-container-org91dfe2b" class="outline-3">
<h3 id="org91dfe2b"><span class="section-number-3">1.5</span> git drill4</h3>
<div class="outline-text-3" id="text-1-5">
</div>
<div id="outline-container-org4b52b0b" class="outline-4">
<h4 id="org4b52b0b">흔한 질문</h4>
<div class="outline-text-4" id="text-org4b52b0b">
<div class="attention">
<p>
흔한 질문중에 하나는 git에서 history는 유지한 채, commit을 변경할 수 있느냐?는 것이다. 결론을
얘기한다면 원론적으로 불가능하다. 첫번째로 commit의 내용을 바꾼다는 것은 commit자체가 바뀐다는 것을
의미한다. commit은 content addressable하다. content의 내용을 sha1으로 바꿔 그것을
파일명,commit이름으로 쓴다. 만일 내용이 바뀌면 기존 commit과 다른 새로운 commit이 만들어지는 것인데,
그러면 history가 깨진다. 왜냐 새로운 commit을 만드는 것은 branch가 있어야 함을 의미하기
때문이다. 말이 좀 복잡해 지는데, linked list를 사용하는 git에서 새로운 commit을 만들면 branch가 그
commit을 가리키는 식으로 삽입이 된다. 즉 새로운 데이터를 삽입하는건 branch가 있는 곳에서 삽입이
된다는 것이다. 중간에 있는 commit을 수정한다는 것은(content addressable한 commit의 특성상) 새로운
commit을 만든다는 것인데, 이렇게 하기위해선, 우선 branch가 그 commit으로 이동해야 한다. 그리고
수정된 commit(실은 새로 생성된 commit)을 연결하는 순간 history는 깨진다. 왜냐 단방향 linked list라서 이전 commit으로
되돌아 갈수가 없게 된다. 참고로 branch를 특정 commmit으로 옮기는 명령어는 reset이란 명령어이다.
</p>
<p>
다시 정리하면,
</p>
<ol class="org-ol">
<li>수정할 commit으로 접근할려면 branch를 움직여야 한다. branch는 reset으로 움직인다. 물론 이전에
head가 해당 branch에 있다는 전제가 있다. head가 그 branch에 없다면, branch를 이동할 수가 없기
때문이다. 여튼 head와 branch가 묶여 있고, reset으로 해당 commit으로 이동했다고 하자.</li>
<li>commit을 수정한다. commit을 수정한다는 것은 새로운 commit이 만들어진다는 뜻이다. 왜냐? content
addressable한 특징때문에, content의 내용이 달라지면 새로운 commit이 되기 때문이다. 현재 branch가
그 commit을 가리키고 있는데, 새로운 commit이 만들어지면, head와 branch는 새로운 commit을 가리키게
된다. 그리고 원래 branch가 있던 commit은 가리키는 branch가 없기 때문에 잃어버리는 history가 된다.</li>
</ol>
</div>
</div>
</div>
<div id="outline-container-org75b0e83" class="outline-4">
<h4 id="org75b0e83">git commit</h4>
<div class="outline-text-4" id="text-org75b0e83">
<div class="attention">
<p>
git commit은 linked list에 commit을 삽입한다. linked list의 HEAD는 branch라고 하는데, default branch는 master란
이름을 가지고 있다. 그리고 git은 변형 linked list를 사용하기 때문에 HEAD라는 branch를 선택하는 변수가 있다.
</p>
<div id="org9db9004" class="figure">
<p><img src="./img/gitcommit.png" alt="gitcommit.png" />
</p>
<p><span class="figure-number">Figure 10: </span>git commit</p>
</div>
</div>
</div>
</div>
<div id="outline-container-org950e0ef" class="outline-4">
<h4 id="org950e0ef">git commit –amend</h4>
<div class="outline-text-4" id="text-org950e0ef">
<div class="attention">
<p>
git commit –amend는 commit을 갱신하거나 삭제하는 효과를 준다. commit을 하고보니, 어떤 파일을
추가시키는 거 깜박했거나, 수정하는것을 깜빡했을때, 우리는 이전 commit지우고, 새로운 commit을
연결하면 되겠네! 할 것이다. 비슷하다. 그런데 이전 잘못 올린 commit은 그대로 둔다. 대신 제대로
반영한 commit의 parent를 잘못만든 commit이 아닌, 그 부모에 연결 시키는 방식을 사용한다. 왜 지우지
않나요? 어차피 linked list구조에서 head나 branch가 지워야 할 commit을 parent로 연결하지 않으면, 그
commit을 접근할 방법이 없다. linked list는 array와 달라서 link가 없으면 접근할 방법이 없다. 그래서
그냥 놨두면, git garbage collector가 branch가 접근할 수 없는 commit을 삭제한다.
</p>
<div id="org393690d" class="figure">
<p><img src="./img/commitamend.png" alt="commitamend.png" />
</p>
<p><span class="figure-number">Figure 11: </span>git commit –amend</p>
</div>
</div>
</div>
</div>
<div id="outline-container-orgcc86f95" class="outline-4">
<h4 id="orgcc86f95">git branch</h4>
<div class="outline-text-4" id="text-orgcc86f95">
<div class="attention">
<p>
git은 변형 linked list를 사용한다. linked list를 처음 만들면 head밖에 없다. 이 상태에서 data가
계속 삽입되는데, linked list는 head로 부터 만들어진다고 보면 된다. 즉 head가 10개 있으면, 10개의
linked list가 있다고 보면 된다. head를 git에선 branch라고 부른다. git branch를 3개 만들면 3개의
line(linked list)가 만들어지는 것을 아래 그림에 표시했다.
</p>
<div id="org3d0e8bc" class="figure">
<p><img src="./img/gitbranch.png" alt="gitbranch.png" />
</p>
<p><span class="figure-number">Figure 12: </span>git branch</p>
</div>
</div>
</div>
</div>
<div id="outline-container-org0f20844" class="outline-4">
<h4 id="org0f20844">git remote</h4>
<div class="outline-text-4" id="text-org0f20844">
<div class="attention">
<p>
원격에 있는 git은 URL을 갖는다. 그 URL에 이름을 붙일 수 있다. 이 때 쓰는 명령어가 git remote이다.
</p>
<pre class="example">
git remote add pb git://github.com/paulbone/ticgit.git
</pre>
<p>
git clone을 하게 되면 원격 URL은 origin이란 이름을 갖게 된다.
</p>
</div>
</div>
</div>
<div id="outline-container-orgf511a5e" class="outline-4">
<h4 id="orgf511a5e">git clone</h4>
<div class="outline-text-4" id="text-orgf511a5e">
<div class="attention">
<p>
git clone은 server에 있는 git repository를 local로 가져온다. local에서 작업할 수 있는 branch가 하나
만들어지는데, commit을 담을 수 있는 주머니가 만들어진다고 보면된다. 그리고 server에 있는 주머니의
주둥이(입구)는 origin/master란 이름을 갖는 입구인데, 움직이지 않는다. server와 local의 동기화를
위해 사용되는 bookmark라고 보면된다. origin은 위에서 말했듯이 원격 git의 URL의 이름이기도 하다. git
remote add로 별도의 이름을 짓지 않았기 때문에 origin이란 default이름을 갖게 된다. 원래 remote
server의 git안에는 수많은 branch가 있을 수 있다. 하지만 clone을 하면 default로 git의 URL주소는
origin이라는 name을 갖고 master branch만 tracking branch가 된다. 나머지 branch는 참조가 없기 때문에
local에선 사용할 수 없다. origin/master 브랜치만 tracking되기 때문에 clone하면 local master branch가
만들어지고 push,pull 모두 remote git server의 master branch에 특별한 기술없이 사용될 수
있는것이다. 예를들어 server에 testing이란 branch만 있다고 하자. 그러면, git clone하면, local에는
origin/testing이라는 branch와 testing이란 branch가 생기게 된다.
</p>
<div id="orgd561442" class="figure">
<p><img src="./img/gitclone.png" alt="gitclone.png" />
</p>
<p><span class="figure-number">Figure 13: </span>git clone</p>
</div>
</div>
</div>
</div>
<div id="outline-container-org389a94b" class="outline-4">
<h4 id="org389a94b">git checkout [head 이동명령어]</h4>
<div class="outline-text-4" id="text-org389a94b">
<div class="attention">
<p>
git checkout은 Head를 이동한다. 그리고 그 Head가 가리키는 commit의 working directory를 복원한다.
git checkout은 commit을 하느냐 혹은 branch를 하느냐에 따라서 그 의도가 다르다.
</p>
<pre class="example">
1.git checkout commit
2.git checkout branch
</pre>
<ol class="org-ol">
<li><p>
git checkout commit: 이것의 의도는, 해당 commit의 내용을 확인하기 위해서다. Head가 해당
commit으로 이동하면서, 그 commit의 working directory를 복원하기 때문에 실제 그당시, 그 commit의
source를 볼수가 있다. 그런데, 여기서 수정은 할 수 없다. 왜냐? 수정을 하고 commit을 하면, 수정된
commit은 수정되기 이전의 commit을 가리킬 수는 있다. 하지만, 해당 linked list의 branch에선 이
새로운 commit으로 이동할 수가 없다. link가 없기 때문이다. 그러면, 이렇게 수정한 commit은 접근할수
없는 미아 commit이 되고 나중에 git garbage colloector에 의해 사라지게 된다. 그렇다면, 수정을 한
후 저장만 하고, commit을 안하면 그냥 갱신된 내용의 commit을 유지하지 않을까? 이것도
안된다.왜냐하면, commit의 내용이 수정되었다는 것은 content addressable한 commit의 특성상 새로운
commit이 되어 야만 한다. 그래서 수정을 하고 저장을 했다 하더라도 git은 동작을 전혀 할수가
없다. 왜냐, git status에 보면, commit에 변경사항이 생겼는데, 이를 처리하지 않아서 아무것도 할 수
없다고 말한다. 그러면 선택은 2가지다. 새로운 commit을 만들거나, unstage하는 경우다. 새로운
commit을 만드는 것은 방금전에 설명한 이유로 안되고, 2번째는 unstage하는 것이기 때문에 commit이
수정되기 전의 상태로 되돌려진다. 즉 수정이 아예 안된다.
</p>
<div id="orge623e73" class="figure">
<p><img src="./img/checkout1.png" alt="checkout1.png" />
</p>
<p><span class="figure-number">Figure 14: </span>git checkout commit</p>
</div></li>
<li>git checkout branch: 이것의 의도는 해당 branch가 가리키는 commit으로 working directory가
복원되고, 수정도 할 수 있고, 새로운 commit을 만드는 것도 가능하다. content-addressable하기 때문에
수정이나, 새로운 commit을 만드는 거나 동일한 일이다. 이전에 설명했듯이, linked list는 하나의
주머니로 봐도 되고, 또한 주머니의 입구는 branch로 비유할수도 있다고했다. 여러 주머니가 있을 경우,
특정 주머니를 선택해야 하는데, 좀 더 정확히는 특정주머니의 입구를 선택해야 한다. 왜냐면, 그래야
commit을 담을 수 있기 때문이다. git checkout은 특정주머니의 입구를 선택하는것이다. 그림으로 보고,
설명한다면, Head를 branch로 움직이는 명령어를 git checkout으로 말할 수 있다. Head를 branch로
움직이는건 일반적이고, 정상적인 동작이다. 특정 commit으로 이동도 가능하지만, 그러나 그런 이동은
위에서 말한바대로 source를 보기위한 목적이다. 수정은 추천되지 않고 바람직하지 않다. 왜냐? history가
깨질 위험이 있기 때문이다. history가 깨진다는 것은 여러 사용자가 공유하는 git이 동기화하는데
문제가 생길 수 있다. 그래서 git에선 commit으로 head를 이동해서 수정하는 것을 허용 하지 않는다.</li>
</ol>
<div id="orga05723e" class="figure">
<p><img src="./img/gitcheckout.png" alt="gitcheckout.png" />
</p>
<p><span class="figure-number">Figure 15: </span>git checkout</p>
</div>
</div>
</div>
</div>
<div id="outline-container-org0f74a94" class="outline-4">
<h4 id="org0f74a94">git log</h4>
<div class="outline-text-4" id="text-org0f74a94">
<div class="attention">
<p>
git log는 head를 기준으로 최초 commit까지의 모든 commit들을 보여준다. 그런데 Head의 원래 역할은
branch를 선택하는게 주 역할이기 때문에, 그 기준으로 살펴보겠다. 즉 branch로 부터 최초 commit까지
모든 commits(history)를 본다고 생각하자. git에서 branch는 linked list라는 주머니의 입구다. 그
입구로 넣어진 commit들은 차곡 차곡 안쪽부터 넣어진다. 그리고 각각의 commit은 연결 되어 있다. 제일
처음 넣어진 commit은 연결이 없다. 그 다음 commit은 처음 넣어진 commit을 가리키고 있다. 주머니안으로
넣어진 commit은 이렇게 단방향 link로 되어 있다. 반대 방향으로 link는 없다. git log는 해당 branch, 즉
주머니의 입구에서 주머니 안쪽의 commit들을 보는 것이다.
</p>
<div id="orgaf4c377" class="figure">
<p><img src="./img/gitlog.png" alt="gitlog.png" />
</p>
<p><span class="figure-number">Figure 16: </span>git log</p>
</div>
<p>
위 그림에서 2개의 주머니가 보인다. 하나는 Testing이란 입구를 가진 주머니, 또 다른 하나는 master란
주머니가 있다. Testing이란 주머니에서 git log를 하면, E - B - A를 볼 수 있다. Master란 주머니에서
git log를 하면 D-C-B-A를 볼 수 있다. 이렇게 볼 수 있는건 parent란 link가 commit사이를 연결하고 있기
때문이다. 이것은 단방향이기 때문에 branch에서 주머니의 마지막 commit까지 보이는거지, 반대로
주머니끝에 있는 commit에서 branch방향으론 볼 수 없다.
</p>
</div>
</div>
</div>
<div id="outline-container-orgd397a16" class="outline-4">
<h4 id="orgd397a16">git reset [branch 이동]</h4>
<div class="outline-text-4" id="text-orgd397a16">
<div class="attention">
<p>
git reset은 branch를 이동하는 명령어다. branch를 움직이기 위해선, 우선 branch가 선택되어야 하기
때문에 HEAD가 branch를 가리키고 있을 것이다. 이 상태에서 git reset commit 하면, 해당 commit으로
branch가 이동하게 된다. 이 이동은 좀 위험한게 있다. 해당 commit으로 이동하면 branch가 있던
commit으로 되돌아갈 방법이 없다. link가 없기 때문이다. history가 깨지는 문제가 있다.
</p>
<div id="orgc1e4c78" class="figure">
<p><img src="./img/gitreset.png" alt="gitreset.png" />
</p>
<p><span class="figure-number">Figure 17: </span>git reset</p>
</div>
</div>