-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd2.tex
426 lines (292 loc) · 8.96 KB
/
add2.tex
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
% This is part of the ``Git First Step''.
% Copyright 2014, 2020 Yoshida Shin.
% See the file slide.tex for copying conditions.
\begin{frame}[t]{git の管理するファイル情報}{使ってみる}
git が管理するファイル情報は、主に以下の 3 個
\begin{itemize}
\item ファイルの相対パス
\item ファイルの中身
\item ファイルのパーミッション
\end{itemize}
\vspace{2ex}
\onslide<2->{
逆に、git は以下のような情報は管理しません。
\begin{itemize}
\item ファイルの所有者
\item ファイルの更新時刻
\end{itemize}
}
\vspace{2ex}
\onslide<3->{
上に列挙した git が管理するファイル情報は ``git add'' で
何度でも workspace から cached に反映可能
}
\end{frame}
\begin{frame}[t]{パーミッションの変更}{使ってみる}
b のパーミッションを変更する
\vspace{4ex}
\onslide*<1>{
workspace を更新
\vspace{2ex}
\$ chmod +x b
}
\onslide*<2>{
workspace を cached に反映
\vspace{2ex}
\$ git add b
}
\end{frame}
\begin{frame}[t]{中で起きている事}{使ってみる}
\begin{columns}
\begin{narrowcolumn}
\begin{block}{workspace}
a \onslide*<1-2>{b \color{black}}\onslide*<3->{\color{green} b \color{black}}c
\end{block}
\begin{block}{cached (index)}
a \onslide*<-4>{b}\onslide*<5->{\color{green}b}
\end{block}
\end{narrowcolumn}
\begin{halfcolumn}
\begin{repository}{repository}
\node (c1) [commit, rectangle split, rectangle split parts=3] at (0em, 0ex) {
\commitmessage{Add a and b.}
\nodepart{second}{a b}
\nodepart{third}{master{\HEAD}}
};
\end{repository}
\end{halfcolumn}
\end{columns}
\vspace{2ex}
\onslide*<2-3>{
\$ chmod +x b
\vspace{2ex}
.git ディレクトリは触っていないので、workspace のみ変更
}
\onslide*<4-5>{
\$ git add b
\vspace{2ex}
\onslide*<-5>{workspace から cached へファイル、ディレクトリをコピー}
}
\end{frame}
\begin{frame}[t]{ファイルの中身を変更}{使ってみる}
b の中身を変更する
\vspace{4ex}
\onslide*<1>{
workspace を更新
\vspace{2ex}
\$ echo 'foo' \textgreater \space b
}
\onslide*<2>{
workspace を cached に反映
\vspace{2ex}
\$ git add b
}
\end{frame}
\begin{frame}[t]{中で起きている事}{使ってみる}
\begin{columns}
\begin{narrowcolumn}
\begin{block}{workspace}
a \onslide*<1-2>{\color{green}b \color{black}}\onslide*<3->{\color{red}b \color{black}}c
\end{block}
\begin{block}{cached (index)}
a \onslide*<-4>{\color{green}b \color{black}}\onslide*<5->{\color{red}b \color{black}}
\end{block}
\end{narrowcolumn}
\begin{halfcolumn}
\begin{repository}{repository}
\node (c1) [commit, rectangle split, rectangle split parts=3] at (0em, 0ex) {
\commitmessage{Add a and b.}
\nodepart{second}{a b}
\nodepart{third}{master{\HEAD}}
};
\end{repository}
\end{halfcolumn}
\end{columns}
\vspace{2ex}
\onslide*<2-3>{
\$ echo 'foo' \textgreater \space b
\vspace{2ex}
.git ディレクトリは触っていないので、workspace のみ変更
}
\onslide*<4-5>{
\$ git add b
\vspace{2ex}
\onslide*<-5>{workspace から cached へファイル、ディレクトリをコピー}
}
\end{frame}
\begin{frame}[t]{ファイルの削除}{使ってみる}
b を削除する
\vspace{4ex}
\onslide*<1>{
workspace を更新
\vspace{2ex}
\$ rm b
}
\onslide*<2>{
workspace を cached に反映
\vspace{2ex}
\$ git add b
}
\end{frame}
\begin{frame}[t]{中で起きている事}{使ってみる}
\begin{columns}
\begin{narrowcolumn}
\begin{block}{workspace}
a \onslide<1-2>{\color{red}b \color{black}}c
\end{block}
\begin{block}{cached (index)}
a \onslide<-4>{\color{red}b \color{black}}
\end{block}
\end{narrowcolumn}
\begin{halfcolumn}
\begin{repository}{repository}
\node (c1) [commit, rectangle split, rectangle split parts=3] at (0em, 0ex) {
\commitmessage{Add a and b.}
\nodepart{second}{a b}
\nodepart{third}{master{\HEAD}}
};
\end{repository}
\end{halfcolumn}
\end{columns}
\vspace{2ex}
\onslide*<2-3>{
\$ rm b
\vspace{2ex}
.git ディレクトリは触っていないので、workspace のみ変更
}
\onslide*<4-5>{
\$ git add b
\vspace{2ex}
\onslide*<-5>{workspace から cached へファイル、ディレクトリをコピー
(「存在しない」という状態をコピーしたので削除)
}
}
\end{frame}
\begin{frame}[t]{ファイルのリネーム}{使ってみる}
a を d というファイル名にリネームする
(ファイル追加と削除を行えばリネームになる)
\vspace{4ex}
\onslide*<1>{
workspace を更新
\vspace{2ex}
\$ mv a d
}
\onslide*<2>{
workspace を cached に反映
\vspace{2ex}
\$ git add a d
}
\end{frame}
\begin{frame}[t]{中で起きている事}{使ってみる}
\begin{columns}
\begin{narrowcolumn}
\begin{block}{workspace}
\onslide<-2>{a }c \onslide<3->{d}
\end{block}
\begin{block}{cached (index)}
\onslide<-4>{a }\onslide<5->{d}
\end{block}
\end{narrowcolumn}
\begin{halfcolumn}
\begin{repository}{repository}
\node (c1) [commit, rectangle split, rectangle split parts=3] at (0em, 0ex) {
\commitmessage{Add a and b.}
\nodepart{second}{a b}
\nodepart{third}{master{\HEAD}}
};
\end{repository}
\end{halfcolumn}
\end{columns}
\vspace{2ex}
\onslide*<2-3>{
\$ mv a d
\vspace{2ex}
.git ディレクトリは触っていないので、workspace のみ変更
}
\onslide*<4-5>{
\$ git add a d
\vspace{2ex}
\onslide*<-5>{workspace から cached へファイル、ディレクトリをコピー}
}
\end{frame}
\begin{frame}[t]{git add コマンドまとめ}{使ってみる}
\begin{itemize}
\item git add \textit{path1} [\textit{path2} [\textit{path3} [...]]]
で workspace の指定された path を cached にコピー
\vspace{2ex}
\item path が ディレクトリの場合、そのディレクトリ以下のファイルを再起的に git add する
\vspace{2ex}
\item workspace のトップディレクトリで git add . と行うと全ファイルを git add できる
\vspace{2ex}
\item git add は何度でも実行可能
(同じファイルを複数回指定しても良い)
\vspace{2ex}
\item ファイルのパーミッションも git add で変更可能
\vspace{2ex}
\item 存在しないファイルを git add すると削除になる
\end{itemize}
\end{frame}
\begin{frame}[t]{commit の追加}{使ってみる}
cached を repository に反映
\vspace{2ex}
\$ git commit -m 'Rename a to d and delete b.'
\end{frame}
\begin{frame}[t]{中で起きている事}{使ってみる}
\begin{columns}
\begin{narrowcolumn}
\begin{block}{workspace}
c d
\end{block}
\begin{block}{cached (index)}
d
\end{block}
\end{narrowcolumn}
\begin{halfcolumn}
\begin{repository}{repository}
\onslide<5->{
\node (c2) [commit, rectangle split, rectangle split parts=3] at (0em, 10ex) {
\commitmessage{Rename a to d and delete b.}
\nodepart{second}{d}
\nodepart{third}{master{\HEAD}}
};
}
\onslide*<3-4>{
\node (c2) [commit, rectangle split, rectangle split parts=2] at (0em, 10ex) {
\commitmessage{Rename a to d and delete b.}
\nodepart{second}{d}
};
}
\onslide<-4>{
\node (c1) [commit, rectangle split, rectangle split parts=3] at (0em, 0ex) {
\commitmessage{Add a and b.}
\nodepart{second}{a b}
\nodepart{third}{master{\HEAD}}
};
}
\onslide*<5->{
\node (c1) [commit, rectangle split, rectangle split parts=2] at (0em, -1.0ex) {
\commitmessage{Add a and b.}
\nodepart{second}{a b}
};
}
\onslide<3->{\draw (c1) -- (c2);}
\end{repository}
\end{halfcolumn}
\end{columns}
\vspace{2ex}
\onslide<2->{
\$ git commit -m 'Rename a to d and delete b.'
\vspace{2ex}
\onslide*<2-3>{
cached を取り込み、message を添えて現在の HEAD を親とする commit を作成
}
\onslide*<4-5>{
HEAD が branch を指している時 (普通はこの状態) は、
その branch の向き先を新しい commit へ変更
}
\onslide*<6>{
HEAD は master へ向いているので、
結果的に新しい commit へ移動
}
}
\end{frame}