-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathindex.html
518 lines (495 loc) · 20.2 KB
/
index.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
<html>
<head>
<meta charset="utf-8">
<title>Tutorial - git init</title>
<link
href='https://fonts.googleapis.com/css?family=Open+Sans'
rel='stylesheet'
type='text/css'
>
<link rel="stylesheet" href="octicons/octicons.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="header">
<h1 class="header-title">git init</h1>
<ul class="header-menu">
<li class="header-menu_item header-menu_item-active">
Tutorial
</li>
<li class="header-menu_item">
<a href="cheatsheet.html">Cheatsheet</a>
</li>
<li class="header-menu_item">
<a href="resources.html">Resources</a>
</li>
<li class="header-menu_item">
<a
class="header-github mega-octicon octicon-mark-github"
href="https://github.com/pel-daniel/git-init"
></a>
</li>
</ul>
</div>
<div class="container">
<div id="side-bar">
<div class="instructions">
<div class="step step1" data-id="1">
<h3><span class="instructions-step">1/13</span> Introduction</h3>
<div class="instructions-message">
<h5>
<span class="octicon octicon-info"></span>
Instructions
</h5>
<p>
Every step in the tutorial starts with a text. At the end of the
text is a button that starts the execution of a git command.
</p>
<p>
After clicking the button 4 things will happen, in the following order:
</p>
<ul>
<li>In the console (at the bottom left): The command will be added and executed.</li>
<li>On the right: An animation will show what the command does.</li>
<li>When the animation ends, the console shows the output of the command.</li>
<li>At the right of the button will appear a link to go to the next step.</li>
</ul>
</div>
<p>
The official definition of git is "a distributed version control system".
But what does it mean? Let's use an example to explain it.
</p>
<p>
In the next table we have some changes we did to a file:
</p>
<table>
<thead>
<tr>
<th>Time</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>July 7, 10:00</td>
<td>Create file <span class="instructions-term">tasks.txt</span>.</td>
</tr>
<tr>
<td>July 7, 10:05</td>
<td>
Add paragraph to file <span class="instructions-term">tasks.txt</span>.
</td>
</tr>
<tr>
<td>July 7, 10:10</td>
<td>
Format the content of <span class="instructions-term">tasks.txt</span>.
</td>
</tr>
<tr>
<td>…</td>
<td>…</td>
</tr>
</tbody>
</table>
<p>
We can think of every row in the table as a version of the file.
So git is a system that helps us track version or changes of files
through time (it is also distributed, but that's a feature for another
tutorial).
</p>
<h4>Git basics</h4>
<p>
To initialize git inside a folder, we use the command
<span class="instructions-term">git init</span>. After executing this
command, git will start tracking changes inside the folder.
</p>
<p>
Internally git have three states (also called areas) where changes
can be in: working directory, staging area, and repository.
</p>
<p>
Click the next button to start the animation.
</p>
<a class="command-trigger">
git init
</a>
<a class="instructions-link next-step hidden">Next</a>
</div>
<div class="hidden step step2" data-id="2">
<h3><span class="instructions-step">2/13</span> First changes</h3>
<p>
The first thing we need to see git in action, is a file.
We can create a new file with the command
<span class="instructions-term">touch</span> and passing a filename
as the first argument (this is a UNIX command not a git one).
</p>
<p>
This command will create the file <span class="instructions-term">tasks.txt</span>.
In this file we will keep a list of tasks we need to do.
</p>
<p>
The working directory area tracks all changes we make inside the
folder. So git will show this new file inside this area.
</p>
<a class="command-trigger">
touch tasks.txt
</a>
<a class="instructions-link next-step hidden">Next</a>
</div>
<div class="hidden step step3" data-id="3">
<h3>
<span class="instructions-step">3/13</span> Adding changes to the
staging area
</h3>
<p>
A <span class="instructions-term">commit</span> is a change, or a
group of changes, we wrap together and tell git to save. It is created
in 2 steps: the first one is adding all the changes we want to the
<span class="instructions-term">staging area</span>.
</p>
<p>
To add changes to the <span class="instructions-term">staging area</span>
we use the command <span class="instructions-term">git add</span>.
The next command moves the changes of the file
<span class="instructions-term">tasks.txt</span> from the working
directory to the staging area.
</p>
<a class="command-trigger">
git add tasks.txt
</a>
<a class="instructions-link next-step hidden">Next</a>
</div>
<div class="hidden step step4" data-id="4">
<h3>
<span class="instructions-step">4/13</span> Creating our first commit
</h3>
<p>
Before, we saw the first of the 2 steps to create a commit.
</p>
<p>
The second step is explicitly telling git to wrap all the changes
currently in the staging area into a commit node. We do this with the
command <span class="instructions-term">git commit</span>.
</p>
<p>
We give each commit a message to easily identify its contents later.
To pass a message to <span class="instructions-term">git commit</span>
we use the option <span class="instructions-term">–m</span>.
</p>
<p>
The next command will create our first commit with the message
<span class="instructions-term">Add file tasks.txt</span>.
</p>
<a class="command-trigger">
git commit –m "Add file tasks.txt"
</a>
<a class="instructions-link next-step hidden">Next</a>
</div>
<div class="hidden step step5" data-id="5">
<h3><span class="instructions-step">5/13</span> Modifying a file</h3>
<p>
The <span class="instructions-term">echo</span> command mixed with
<span class="instructions-term">>></span> adds lines to the
end of a file.
</p>
<p>
The first task we want to do is to <span class="instructions-term">Buy milk</span>.
So we will add it to our file <span class="instructions-term">tasks.txt</span>
with the <span class="instructions-term">echo</span> command.
</p>
<p>
Look how git tells us that the file has changed by adding it to the
working directory area.
</p>
<a class="command-trigger">
echo "Buy milk" >> tasks.txt
</a>
<a class="instructions-link next-step hidden">Next</a>
</div>
<div class="hidden step step6" data-id="6">
<h3><span class="instructions-step">6/13</span> Git status</h3>
<p>
Another useful command is <span class="instructions-term">git status</span>.
This command shows us the changes we have inside the working directory
and the staging area.
</p>
<p>
Look at the output of the command in the console (bottom left).
<span class="instructions-term">git status</span> will tell us that
the changes are not staged (this means that the changes are inside
the working directory). All the files with changes inside the working
directory will be shown in red. And the file
<span class="instructions-term">tasks.txt</span> has a modified status
because we add a line to it in the last step.
</p>
<a class="command-trigger">
git status
</a>
<a class="instructions-link next-step hidden">Next</a>
</div>
<div class="hidden step step7" data-id="7">
<h3>
<span class="instructions-step">7/13</span> Detailed list of changes
</h3>
<p>
The command <span class="instructions-term">git status</span> just
shows us the names of the files with changes. If we want to know what
changed inside each file of the working directory, we can use the
command <span class="instructions-term">git diff</span>.
</p>
<p>
In the output of <span class="instructions-term">git diff</span>,
the lines that we added to the file are shown in green, and the ones
that we removed are shown in red.
</p>
<a class="command-trigger">
git diff
</a>
<a class="instructions-link next-step hidden">Next</a>
</div>
<div class="hidden step step8" data-id="8">
<h3><span class="instructions-step">8/13</span> Add again</h3>
<p>
We want to create another commit with the changes we did to
<span class="instructions-term">tasks.txt</span>. We need to add the
changes to the staging area again with the command
<span class="instructions-term">git add</span>.
</p>
<a class="command-trigger">
git add tasks.txt
</a>
<a class="instructions-link next-step hidden">Next</a>
</div>
<div class="hidden step step9" data-id="9">
<h3><span class="instructions-step">9/13</span> Git status 2</h3>
<p>
We can use the command <span class="instructions-term">git status</span>
again to see the message git gives us when we have staged changes.
The file <span class="instructions-term">tasks.txt</span> still
appears with a modified status, but the color has changed to green
which means the changes are inside the staging area.
</p>
<a class="command-trigger">
git status
</a>
<a class="instructions-link next-step hidden">Next</a>
</div>
<div class="hidden step step10" data-id="10">
<h3><span class="instructions-step">10/13</span> Detailed changes 2</h3>
<p>
In step 7 we used the command <span class="instructions-term">git diff</span>
to see the detailed list of changes we had inside the working directory.
</p>
<p>
This command can also show the changes inside the staging area, if we
pass the option <span class="instructions-term">––cached</span> to it.
</p>
<p>
The output has the same color code: the lines that we added are shown
in green, and the ones that we removed are shown in red.
</p>
<a class="command-trigger">
git diff ––cached
</a>
<a class="instructions-link next-step hidden">Next</a>
</div>
<div class="hidden step step11" data-id="11">
<h3><span class="instructions-step">11/13</span> Our second commit</h3>
<p>
We want the changes in the staging area to be a new commit.
We use the command <span class="instructions-term">git commit</span>
again, and pass a descriptive message that identifies this commit.
</p>
<a class="command-trigger">
git commit –m "Add first task"
</a>
<a class="instructions-link next-step hidden">Next</a>
</div>
<div class="hidden step step12" data-id="12">
<h3><span class="instructions-step">12/13</span> Seeing our commits</h3>
<p>
The command that completes this tutorial is
<span class="instructions-term">git log</span>. This command shows
us the commits we have made.
</p>
<p>
<span class="instructions-term">git log</span> has various options
to show the output with different detail levels. We use the option
<span class="instructions-term">––oneline</span> to see the output
in a short format.
</p>
<a class="command-trigger">
git log ––oneline
</a>
<a class="instructions-link next-step hidden">Next</a>
</div>
<div class="hidden step step13" data-id="13">
<h3><span class="instructions-step">13/13</span> Closing</h3>
<p>
This tutorial has all the basic commands you need to start using git
in your personal projects.
</p>
<p>
There is a lot more to learn about git, look at the <a class="instructions-link"
href="resources.html">Resources</a> section for a list of next steps to expand your knowledge
of git.
</p>
<p>
Also you can use the <a class="instructions-link" href="cheatsheet.html">
Cheatsheet</a> section as a reference. It has all the commands in this
tutorial with explanations for the most used options.
</p>
</div>
</div>
<div class="console">
<div class="console-command-group step1">
<span class="console-prompt">></span>
<span class="console-bash-command"></span>
<div class="console-output hidden">
Initialized empty git repository in my_folder/.git/
</div>
</div>
<div class="console-command-group step2">
<span class="console-prompt hidden">></span>
<span class="console-bash-command"></span>
</div>
<div class="console-command-group step3">
<span class="console-prompt hidden">></span>
<span class="console-bash-command"></span>
</div>
<div class="console-command-group step4">
<span class="console-prompt hidden">></span>
<span class="console-bash-command"></span>
<div class="console-output hidden">
<div>
[master (root-commit) <span>cc04c1f</span>] <span>Add file tasks.txt</span>
</div>
<div> 1 file changed, 0 insertions(+), 0 deletions(-)</div>
<div> create mode 100644 <span>fileName</span></div>
</div>
</div>
<div class="console-command-group step5">
<span class="console-prompt hidden">></span>
<span class="console-bash-command"></span>
</div>
<div class="console-command-group step6">
<span class="console-prompt hidden">></span>
<span class="console-bash-command"></span>
<div class="console-output hidden">
<div>On branch master</div>
<div>Changes not staged for commit:</div>
<div class="console-indented-output">
(use "git add <file>..." to update what will be committed)
</div>
<div class="console-indented-output">
(use "git checkout –– <file>..." to discard changes in working directory)
</div>
<div class="console-indented2-output console-red-output">
modified: tasks.txt
</div>
<div>
no changes added to commit (use "git add" and/or "git commit –a")
</div>
</div>
</div>
<div class="console-command-group step7">
<span class="console-prompt hidden">></span>
<span class="console-bash-command"></span>
<div class="console-output hidden">
<div>diff ––git a/tasks.txt b/tasks.txt</div>
<div>index e69de29..557fb5d 100644</div>
<div>––– a/tasks.txt</div>
<div>+++ b/tasks.txt</div>
<div class="console-blue-output">@@ -0,0 +1 @@</div>
<div class="console-green-output">+– Buy milk</div>
</div>
</div>
<div class="console-command-group step8">
<span class="console-prompt hidden">></span>
<span class="console-bash-command"></span>
</div>
<div class="console-command-group step9">
<span class="console-prompt hidden">></span>
<span class="console-bash-command"></span>
<div class="console-output hidden">
<div>On branch master</div>
<div>Changes to be commited:</div>
<div class="console-indented-output">
(use "git reset HEAD <file>..." to unstage)
</div>
<div class="console-indented2-output console-green-output">
modified: tasks.txt
</div>
</div>
</div>
<div class="console-command-group step10">
<span class="console-prompt hidden">></span>
<span class="console-bash-command"></span>
<div class="console-output hidden">
<div>diff ––git a/tasks.txt b/tasks.txt</div>
<div>index e69de29..557fb5d 100644</div>
<div>––– a/tasks.txt</div>
<div>+++ b/tasks.txt</div>
<div class="console-blue-output">@@ -0,0 +1 @@</div>
<div class="console-green-output">+– Buy milk</div>
</div>
</div>
<div class="console-command-group step11">
<span class="console-prompt hidden">></span>
<span class="console-bash-command"></span>
<div class="console-output hidden">
<div>[master <span>ff5dac2</span>] <span>Add first task</span></div>
<div> 1 file changed, 1 insertions(+)</div>
</div>
</div>
<div class="console-command-group step12">
<span class="console-prompt hidden">></span>
<span class="console-bash-command"></span>
<div class="console-output hidden">
<div>
<span class="console-yellow-output">ff5dac2</span>
Add first task
</div>
<div>
<span class="console-yellow-output">cc04c1f</span>
Add file tasks.txt
</div>
</div>
</div>
<div class="console-command-group step13">
<span class="console-prompt hidden">></span>
<span class="console-bash-command"></span>
</div>
</div>
</div>
<div id="app">
<div class="area hidden">
<h2 class="area-title hidden">Working directory</h2>
<div id="working-dir">
</div>
</div>
<div class="area hidden">
<h2 class="area-title hidden">Staging area</h2>
<div id="staging">
</div>
</div>
<div class="area hidden">
<h2 class="area-title hidden">Local repository</h2>
<div id="local-repository">
</div>
</div>
</div>
</div>
<script
src="https://code.jquery.com/jquery-2.2.4.min.js"
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
crossorigin="anonymous">
</script>
<script
src="https://code.jquery.com/color/jquery.color-2.1.2.min.js"
type="text/javascript">
</script>
<script type="text/javascript" src="app.js"></script>
</body>
</html>