forked from Asabeneh/10-days-of-git-and-github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1068 lines (1023 loc) · 67.4 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
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>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="description"
content="A step by step guide learn basics of command lines, Git and GitHub, GitHub workflow"
/>
<meta
name="keywords"
content="Git, GitHub, Command lines, Git bash, terminal, Web development, DevOps"
/>
<meta name="author" content="Asabeneh Yetayeh" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.3.1/css/all.css"
integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU"
crossorigin="anonymous"
/>
<title>10 Days of Git and GitHub</title>
<style>
* {
box-sizing: border-box;
}
html,
body {
max-width: 100%;
overflow-x: hidden !important;
}
body {
margin: 0;
color: #1c1313;
word-wrap: break-word;
}
header {
background-color: #24292e;
color: white;
padding: 25px;
text-align: center;
}
.day {
text-transform: uppercase;
color: black;
font-weight: 600;
}
li > a {
text-decoration: none;
}
li > a,
li > a:active,
li > a:visited {
color: #1c1313;
}
.header-title {
text-align: center;
text-transform: uppercase;
/* transition: color 3s;
transition-timing-function: ease-in;
background-color: rgba(204, 189, 189, 0.25);
padding: 25px; */
}
sub a {
color: white;
text-decoration: none;
}
img {
max-width: 100%;
}
main {
width: 70%;
margin: 50px auto;
}
pre {
overflow-x: auto;
background-color: rgb(114, 108, 108);
background-color: #24292e;
color: white;
padding: 10px;
}
.fa-arrow-alt-circle-up,
.fa-arrow-alt-circle-down {
margin-top: 25px;
color: rgb(133, 132, 129);
font-size: 30px;
}
footer {
background-color: #24292e;
color: white;
padding: 25px;
text-align: center;
}
@media (max-width: 758px) {
main {
width: 95%;
margin: 5px auto;
}
}
</style>
</head>
<body>
<div id="wrapper">
<header>
<div align="center">
<h1 class="header-title">10 Days of Git and GitHub</h1>
<a
class="header-badge"
target="_blank"
href="https://www.linkedin.com/in/asabeneh/"
>
<img
src="https://img.shields.io/badge/style--5eba00.svg?label=LinkedIn&logo=linkedin&style=social" /></a
><a
class="header-badge"
target="_blank"
href="https://twitter.com/Asabeneh"
>
<img
alt="Twitter Follow"
src="https://img.shields.io/twitter/follow/asabeneh?style=social"
/>
</a>
<br />
<sub
>Author:
<a href="https://www.linkedin.com/in/asabeneh/" target="_blank"
>Asabeneh Yetayeh</a
><br />
<small> First Edition: Jan 25, 2021</small>
</sub>
<br />
<div className="arrow">
<a href="#footer-wrapper" rel="noopener noreferrer">
<i class="far fa-arrow-alt-circle-down"></i>
</a>
</div>
</div>
</header>
<main>
<div>
<small
>Support the <strong>author</strong> to create more educational
materials</small
>
<br />
<a href="https://www.paypal.me/asabeneh"
><img
src="./images/paypal_lg.png"
src="./images/paypal_lg.jpg"
alt="Paypal Logo"
style="width: 10%"
/></a>
</div>
<ul>
<li>
<a class="day" href="#day-1">Day 1</a>
<ul>
<li>
<a href="#basic-command-lines">Basic Command Lines</a>
<ul>
<li>
<a href="#current-working-directory"
>Current working directory</a
>
</li>
<li>
<a href="#navigating-directory">Navigating directory</a>
</li>
<li><a href="#making-directory">Making Directory</a></li>
<li>
<a href="#list-files-and-directories"
>List files and directories</a
>
</li>
<li><a href="#detail-list">Detail list</a></li>
<li><a href="#creating-file">Creating file</a></li>
<li>
<a href="#opening-and-writing-on-file"
>Opening and writing on file</a
>
</li>
<li>
<a href="#opening-file-to-read">Opening file to read</a>
</li>
<li><a href="#copy-file">Copy file</a></li>
<li><a href="#rename-file">Rename file</a></li>
<li>
<a href="#moving-file-and-directory"
>Moving file and directory</a
>
</li>
<li>
<a href="#delete-file-and-directory"
>Delete file and directory</a
>
</li>
</ul>
</li>
</ul>
</li>
<li>
<a class="day" href="#day-2">Day 2</a>
<ul>
<li>
<a href="#git-and-github">Git and GitHub</a>
<ul>
<li><a href="#1-install-git">1. Install Git</a></li>
<li>
<a href="#2-checking-status-of-the-repository"
>2. Checking status of the repository</a
>
</li>
<li>
<a href="#3-configure-your-name-and-your-email"
>3. Configure your name and your email</a
>
</li>
<li>
<a href="#4-create-a-local-git-repository"
>4. Create a local git repository</a
>
</li>
<li><a href="#5-initialize-git">5. Initialize Git</a></li>
<li>
<a href="#6-add-file-to-the-staging-area"
>6. Add file to the staging area</a
>
</li>
<li><a href="#7-unstage-a-file">7. Unstage a file</a></li>
<li>
<a href="#8-commit-the-changes">8. Commit the changes</a>
</li>
<li><a href="#9-git-log">9. Git log</a></li>
<li><a href="#10-git-check-out">10. Git check out</a></li>
<li>
<a href="#11-creating-a-branch">11. Creating a branch</a>
</li>
<li>
<a href="#12-create-account-on-github"
>12. Create account on GitHub</a
>
</li>
<li>
<a href="#13-create-repository-on-github"
>13. Create Repository on GitHub</a
>
</li>
<li>
<a href="#14-connecting-git-with-remote-repository"
>14. Connecting git with remote repository</a
>
</li>
<li><a href="#15-push">15. Push</a></li>
<li><a href="#16-merge">16. Merge</a></li>
<li><a href="#17-pull">17. Pull</a></li>
</ul>
</li>
<li>
<a href="#git-cheat-sheet">Git cheat sheet:</a>
<ul>
<li><a href="#pull-request">pull request</a></li>
</ul>
</li>
</ul>
</li>
<li>
<a class="day" href="#day-3">Day 3</a>
<ul>
<li>
<a href="#advanced-git-features">Advanced git features</a>
</li>
<li><a href="#github-page">GitHub page</a></li>
<li><a href="#github-wiki">GitHub wiki</a></li>
<li><a href="#github-markdown">GitHub markdown</a></li>
</ul>
</li>
<li>
<a class="day" href="#day-4">Day 4</a>
<ul>
<li>
<a href="#collaborating-on-github">Collaborating on GitHub</a>
</li>
<li><a href="#github-workflow">GitHub workflow</a></li>
</ul>
</li>
<li><a class="day" href="#day-5">Day 5</a></li>
</ul>
<h1 id="day-1">Day 1</h1>
<h2 id="basic-command-lines">Basic Command Lines</h2>
<p>
Developers need to know basic Unix commands. Some tasks necessary need
to be done using git bash, mac terminal, or window command prompt. In
this tutorial, we will use git bash to learn the basics of the Unix
command which you may need as a developer. This is not an exhaustive
list but it is enough for daily uses. To make use of git bash first
you should install
<a href="https://git-scm.com/">git</a>. You can install by just
clicking the next button up to the end of the installation.
</p>
<h3 id="current-working-directory">Current working directory</h3>
<p>Checking the working directory using the command <em>pwd</em>.</p>
<pre><code class="lang-sh"><span class="hljs-selector-tag">Asabeneh</span>@<span class="hljs-keyword">DESKTOP</span>-<span class="hljs-keyword">KGC1AKC</span> MINGW64 ~$ pwd
/c/Users/Asabeneh
</code></pre>
<h3 id="navigating-directory">Navigating directory</h3>
<p>Now, let's go to the Desktop using cd(change directory).</p>
<pre><code class="lang-sh">Asabeneh<span class="hljs-variable">@DESKTOP</span>-KGC1AKC MINGW64 ~<span class="hljs-variable">$ </span>cd Desktop
Asabeneh<span class="hljs-variable">@DESKTOP</span>-KGC1AKC MINGW64 ~<span class="hljs-regexp">/Desktop</span>
</code></pre>
<p>To check where you are at, use the <em>pwd</em> command age</p>
<pre><code class="lang-sh">Asabeneh<span class="hljs-meta">@DESKTOP</span>-KGC1AKC MINGW64 ~/Desktop$ pwd
<span class="hljs-regexp">/c/</span>Users<span class="hljs-regexp">/Asabeneh/</span>Desktop
</code></pre>
<p>
We use <em>cd</em> to get into a directory(folder) and we use
<em>cd..</em> to get out from a directory, in other words, we use
<em>cd</em> to go forward into a directory and <em>cd ..</em> to go
backward from a directory.
</p>
<h3 id="making-directory">Making Directory</h3>
<p>
Now, let's create a directory inside the Desktop. Call the name of
the directory, 10-days-of-code. You give it any name but I am in favor
of this name. Use the <em>mkdir</em> command to make a
directory(folder)
</p>
<pre><code class="lang-sh">Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop$ mkdir <span class="hljs-number">10</span>-days-<span class="hljs-keyword">of</span>-<span class="hljs-keyword">code</span>
</code></pre>
<p>
Now let's go to the 10-days-of-code folder using
<em>cd</em> command.
</p>
<pre><code class="lang-sh">Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop$ cd <span class="hljs-number">10</span>-days-<span class="hljs-keyword">of</span>-<span class="hljs-keyword">code</span>
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-days-<span class="hljs-keyword">of</span>-<span class="hljs-keyword">code</span>
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-days-<span class="hljs-keyword">of</span>-<span class="hljs-keyword">code</span>$ pwd
/c/Users/Asabeneh/Desktop/<span class="hljs-number">10</span>-days-<span class="hljs-keyword">of</span>-<span class="hljs-keyword">code</span>
</code></pre>
<h3 id="list-files-and-directories">List files and directories</h3>
<p>
We can check the files and directories we have in a directory(folder)
using the <em>ls</em> command.
</p>
<pre><code class="lang-sh">Asabeneh<span class="hljs-variable">@DESKTOP</span>-KGC1AKC MINGW64 ~<span class="hljs-regexp">/Desktop/</span><span class="hljs-number">10</span>-days-of-code<span class="hljs-variable">$ </span>ls
</code></pre>
<p>
No files or directories were found in the 10-days-of-code folder
because we didn't create them yet. Let's create some
directories
</p>
<pre><code class="lang-sh">Asabeneh<span class="hljs-variable">@DESKTOP</span>-KGC1AKC MINGW64 ~<span class="hljs-regexp">/Desktop/</span><span class="hljs-number">10</span>-days-of-code<span class="hljs-variable">$ </span>mkdir day-<span class="hljs-number">1</span>
</code></pre>
<p>
Now let's check if there are some files or directories in the
10-days-of-code folder.
</p>
<pre><code class="lang-sh">Asabeneh<span class="hljs-variable">@DESKTOP</span>-KGC1AKC MINGW64 ~<span class="hljs-regexp">/Desktop/</span><span class="hljs-number">10</span>-days-of-code<span class="hljs-variable">$ </span>ls
day-<span class="hljs-number">1</span>
</code></pre>
<p>Now, you see a day-1 folder that you created.</p>
<p>
Now let's create multiple folders at one and use <em>ls</em> to
see all the directories we have in the 10-days-of-code folder.
</p>
<p>Making multiple folders at once</p>
<pre><code class="lang-sh">Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>$ mkdir <span class="hljs-built_in">day</span>-<span class="hljs-number">2</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">6</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">7</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">8</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">9</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">10</span>
</code></pre>
<p>
Using <em>ls</em> we can see all the directories we have in the
10-days-of-code
</p>
<pre><code class="lang-sh">Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>
$ ls
<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">10</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">2</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">6</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">7</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">8</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">9</span>
</code></pre>
<h3 id="detail-list">Detail list</h3>
<p>
Let's see a detailed list of the directories using multiple
commands,
<em>ls -la</em>.
</p>
<pre><code class="lang-sh">Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/10-days-of-code
$ ls -la
total 20
drwxr-xr-x<span class="hljs-number"> 1 </span>Asabeneh<span class="hljs-number"> 197121 </span>0 Jan<span class="hljs-number"> 19 </span>02:16 .
drwxr-xr-x<span class="hljs-number"> 1 </span>Asabeneh<span class="hljs-number"> 197121 </span>0 Jan<span class="hljs-number"> 19 </span>02:05 ..
drwxr-xr-x<span class="hljs-number"> 1 </span>Asabeneh<span class="hljs-number"> 197121 </span>0 Jan<span class="hljs-number"> 19 </span>02:12 day-1
drwxr-xr-x<span class="hljs-number"> 1 </span>Asabeneh<span class="hljs-number"> 197121 </span>0 Jan<span class="hljs-number"> 19 </span>02:16 day-10
drwxr-xr-x<span class="hljs-number"> 1 </span>Asabeneh<span class="hljs-number"> 197121 </span>0 Jan<span class="hljs-number"> 19 </span>02:16 day-2
drwxr-xr-x<span class="hljs-number"> 1 </span>Asabeneh<span class="hljs-number"> 197121 </span>0 Jan<span class="hljs-number"> 19 </span>02:16 day-3
drwxr-xr-x<span class="hljs-number"> 1 </span>Asabeneh<span class="hljs-number"> 197121 </span>0 Jan<span class="hljs-number"> 19 </span>02:16 day-4
drwxr-xr-x<span class="hljs-number"> 1 </span>Asabeneh<span class="hljs-number"> 197121 </span>0 Jan<span class="hljs-number"> 19 </span>02:16 day-5
drwxr-xr-x<span class="hljs-number"> 1 </span>Asabeneh<span class="hljs-number"> 197121 </span>0 Jan<span class="hljs-number"> 19 </span>02:16 day-6
drwxr-xr-x<span class="hljs-number"> 1 </span>Asabeneh<span class="hljs-number"> 197121 </span>0 Jan<span class="hljs-number"> 19 </span>02:16 day-7
drwxr-xr-x<span class="hljs-number"> 1 </span>Asabeneh<span class="hljs-number"> 197121 </span>0 Jan<span class="hljs-number"> 19 </span>02:16 day-8
drwxr-xr-x<span class="hljs-number"> 1 </span>Asabeneh<span class="hljs-number"> 197121 </span>0 Jan<span class="hljs-number"> 19 </span>02:16 day-9
</code></pre>
<p>
Using the above command, we can see the detailed view of a directory
or a file
</p>
<h3 id="creating-file">Creating file</h3>
<p>
Now, let's see how to create a file. We can use the
<em>touch</em> command to write a file.
</p>
<pre><code class="lang-sh">Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>$ touch <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>.txt
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>$ ls
<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">10</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">2</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">6</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">7</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">8</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">9</span>
</code></pre>
<p>
As you can see, there is day-1.txt in the list. That means we have
created the day-1.txt file inside the 10-days-of-code folder. You can
also you
<em>ls -la</em> command to use the detailed view of the folders and
file.
</p>
<h3 id="opening-and-writing-on-file">Opening and writing on file</h3>
<p>
Now, let's open the day-1.txt file and add some text to it. We use
the
<em>nano</em> command to open and write.
</p>
<pre><code class="lang-sh">Asabeneh<span class="hljs-variable">@DESKTOP</span>-KGC1AKC MINGW64 ~<span class="hljs-regexp">/Desktop/</span><span class="hljs-number">10</span>-days-of-code<span class="hljs-variable">$ </span>nano day-<span class="hljs-number">1</span>.txt
</code></pre>
<p><img src="/images/nano.png" alt="" /></p>
<p>
As you can see from the above figure, the cursor is active and you can
write on the pad. You can only use arrow keys to move the cursor left,
right, up, and down. Let's write some text on the opened pad.
There are instructors at the bottom that tells how to exit. For
instance ctrl + x is to exit. When you exit either you save or cancel
which comes when you click ctrl + x.
</p>
<p><img src="/images/writting_on_nano.png" alt="" /></p>
<p>
Now you can save the modified file by writing Y or you can cancel it
by clicking ctrl + c.
</p>
<p>After you write Y then click enter.</p>
<h3 id="opening-file-to-read">Opening file to read</h3>
<p>We can use the <em>cat</em> command just only to read the file.</p>
<pre><code class="lang-sh">Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-days-<span class="hljs-keyword">of</span>-code$ cat <span class="hljs-built_in">day</span><span class="hljs-number">-1.</span>txt
This <span class="hljs-keyword">is</span> <span class="hljs-keyword">my</span> <span class="hljs-keyword">first</span> <span class="hljs-built_in">text</span>. I have never written <span class="hljs-keyword">on</span> nano <span class="hljs-built_in">text</span> editor <span class="hljs-keyword">before</span>
</code></pre>
<h3 id="copy-file">Copy file</h3>
<p>
Let's have day-1-backup.txt from day-1.txt by copying using the
<em>cp</em> command.
</p>
<pre><code class="lang-sh">Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>
$ cp <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>-backup.txt
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span> $ ls
<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">10</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>-backup.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">2</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">6</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">7</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">8</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">9</span>
</code></pre>
<h3 id="rename-file">Rename file</h3>
<p>
The <em>mv</em> command is used both to change the name of a file and
to move a file into a different directory.
</p>
<p>
Let's have more files in the 10-days-of-code folder. We can use
the
<em>touch</em> command to create files.
</p>
<pre><code class="lang-sh">Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>$ touch <span class="hljs-built_in">day</span>-<span class="hljs-number">2</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span>.txt
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>$ ls
<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">10</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">2</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">6</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">8</span>
<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>-backup.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">2</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">7</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">9</span>
</code></pre>
<p>
Now, let's rename the day-2.txt to second-day.txt using the
<em>mv</em> command.
</p>
<pre><code class="lang-sh">Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-days-<span class="hljs-keyword">of</span>-code$ mv <span class="hljs-built_in">day</span><span class="hljs-number">-2.</span>txt <span class="hljs-keyword">second</span>-<span class="hljs-built_in">day</span>.txt
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-days-<span class="hljs-keyword">of</span>-code$ ls
<span class="hljs-built_in">day</span><span class="hljs-number">-1</span> <span class="hljs-built_in">day</span><span class="hljs-number">-10</span> <span class="hljs-built_in">day</span><span class="hljs-number">-2</span> <span class="hljs-built_in">day</span><span class="hljs-number">-3.</span>txt <span class="hljs-built_in">day</span><span class="hljs-number">-4.</span>txt <span class="hljs-built_in">day</span><span class="hljs-number">-5.</span>txt <span class="hljs-built_in">day</span><span class="hljs-number">-7</span> <span class="hljs-built_in">day</span><span class="hljs-number">-9</span>
<span class="hljs-built_in">day</span><span class="hljs-number">-1.</span>txt <span class="hljs-built_in">day</span><span class="hljs-number">-1</span>-backup.txt <span class="hljs-built_in">day</span><span class="hljs-number">-3</span> <span class="hljs-built_in">day</span><span class="hljs-number">-4</span> <span class="hljs-built_in">day</span><span class="hljs-number">-5</span> <span class="hljs-built_in">day</span><span class="hljs-number">-6</span> <span class="hljs-built_in">day</span><span class="hljs-number">-8</span> <span class="hljs-keyword">second</span>-<span class="hljs-built_in">day</span>.txt
</code></pre>
<p>Let's rename the day-10 directory to day-ten.</p>
<pre><code class="lang-sh">Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>$ mv <span class="hljs-built_in">day</span>-<span class="hljs-number">10</span> <span class="hljs-built_in">day</span>-ten
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>$ ls
<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>-backup.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">6</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">8</span> <span class="hljs-built_in">day</span>-ten
<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">2</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">7</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">9</span> <span class="hljs-built_in">second</span>-day.txt
</code></pre>
<h3 id="moving-file-and-directory">Moving file and directory</h3>
<p>
The <em>mv</em> and <em>cp</em> commands can be used to put files into
a directory. The <em>cp</em> moves the copy of the file or the folder
to another folder, however, mv just move it without copying. Let's
move the day-1.txt day-1 folder.
</p>
<pre><code class="lang-sh">Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>$ mv <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>$ ls
<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">2</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">7</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">9</span> <span class="hljs-built_in">second</span>-day.txt
<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>-backup.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">6</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">8</span> <span class="hljs-built_in">day</span>-ten
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>$ cd <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>/<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>$ ls
<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>.txt
</code></pre>
<p>
Let's try to move a file using the <em>cp</em> command. Let's
move the day-1-backup.txt to day-1 folder
</p>
<pre><code class="lang-sh">Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-git/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>
$ cp <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>-backup.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-git/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>
$ cd <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-git/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>/<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>
$ ls
<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>-backup.txt
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-git/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>/<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>
$ cd ..
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-git/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>
$ ls
<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">2</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">7</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">9</span> <span class="hljs-built_in">second</span>-day.txt
<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>-backup.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">6</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">8</span> <span class="hljs-built_in">day</span>-ten
</code></pre>
<p>
The copied version of day-1-backup.txt moved to a day-1 folder. Now
let's create multiple backup files first and move them to a backup
folder
</p>
<pre><code class="lang-sh">Asabeneh<span class="hljs-variable">@DESKTOP</span>-KGC1AKC MINGW64 ~<span class="hljs-regexp">/Desktop/</span><span class="hljs-number">10</span>-days-of-code<span class="hljs-variable">$ </span>mkdir backups
Asabeneh<span class="hljs-variable">@DESKTOP</span>-KGC1AKC MINGW64 ~<span class="hljs-regexp">/Desktop/</span><span class="hljs-number">10</span>-days-of-code<span class="hljs-variable">$ </span>cd backups
Asabeneh<span class="hljs-variable">@DESKTOP</span>-KGC1AKC MINGW64 ~<span class="hljs-regexp">/Desktop/</span><span class="hljs-number">10</span>-days-of-code/backups<span class="hljs-variable">$ </span>touch day-<span class="hljs-number">2</span>-backup.txt day-<span class="hljs-number">3</span>-backup.txt
Asabeneh<span class="hljs-variable">@DESKTOP</span>-KGC1AKC MINGW64 ~<span class="hljs-regexp">/Desktop/</span><span class="hljs-number">10</span>-days-of-code/backups<span class="hljs-variable">$ </span>ls
day-<span class="hljs-number">2</span>-backup.txt day-<span class="hljs-number">3</span>-backup.txt
</code></pre>
<p>Moving multiple files</p>
<pre><code class="lang-sh">Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>
$ mv -<span class="hljs-built_in">t</span> backups <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>-backup.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">2</span>-backup.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span>-backup.txt
</code></pre>
<pre><code class="lang-sh">Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>
$ cd backups/
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>/backups
$ ls
<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>-backup.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">2</span>-backup.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span>-backup.txt
</code></pre>
<h3 id="delete-file-and-directory">Delete file and directory</h3>
<p>
Let's remove the file using the <em>rm</em> command. Let's
remove the day-1-backup.txt file from the day-1 folder.
</p>
<pre><code class="lang-sh">Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>
$ cd <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>/<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>
$ ls
<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>-backup.txt
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>/<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>
$ rm <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>-backup.txt
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>/<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>$ ls
<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span>.txt
</code></pre>
<p>
Let's delete the day-ten folder using <em>rmdir</em> command. The
<em>rmdir</em> delete a folder.
</p>
<pre><code class="lang-sh">Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>
$ rmdir <span class="hljs-built_in">day</span>-ten
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>
$ ls
backups <span class="hljs-built_in">day</span>-<span class="hljs-number">2</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">7</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">9</span>
<span class="hljs-built_in">day</span>-<span class="hljs-number">1</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">6</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">8</span> <span class="hljs-built_in">second</span>-day.txt
</code></pre>
<p>
Now, let's copy the backups folder to backups-2 and backup-3 using
<em>cp</em> command. Then we will delete backups-3. The
<em>cp</em> with <em>-r</em> has been used to copy it recursively.
</p>
<pre><code class="lang-sh">Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>$ cp -r backups backups-<span class="hljs-number">2</span>
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>$ ls
backups <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">6</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">8</span> <span class="hljs-built_in">second</span>-day.txt
backups-<span class="hljs-number">2</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">2</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">7</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">9</span>
</code></pre>
<p>Now let's do the above step to create backups-3</p>
<pre><code class="lang-sh">Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>
$ cp -r backups backups-<span class="hljs-number">3</span>
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>
$ ls
backups backups-<span class="hljs-number">3</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">2</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">7</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">9</span>
backups-<span class="hljs-number">2</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">6</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">8</span> <span class="hljs-built_in">second</span>-day.txt
</code></pre>
<p>
Now the backups-3 has files and neither the <em>rm</em> nor the
<em>rmdir</em> deletes it. Therefore, we can use multiple commands to
delete it. Let's try it with the following command.
</p>
<pre><code class="lang-sh">Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>$ rm -rf backups-<span class="hljs-number">3</span>
Asabeneh@DESKTOP-KGC1AKC MINGW64 ~/Desktop/<span class="hljs-number">10</span>-<span class="hljs-built_in">days</span>-of-<span class="hljs-built_in">code</span>$ ls
backups <span class="hljs-built_in">day</span>-<span class="hljs-number">1</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">6</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">8</span> <span class="hljs-built_in">second</span>-day.txt
backups-<span class="hljs-number">2</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">2</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">3</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">4</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">5</span>.txt <span class="hljs-built_in">day</span>-<span class="hljs-number">7</span> <span class="hljs-built_in">day</span>-<span class="hljs-number">9</span>
</code></pre>
<p><em>Congratulations! Now you knew basic command lines</em></p>
<h1 id="day-2">Day 2</h1>
<h2 id="git-and-github">Git and GitHub</h2>
<p>
Git is a version control software. In one way or the other you may
need to use a git and a GitHub together.
</p>
<p>
You need to use git and GitHub either to store your projects on the
cloud or to collaborate with your team. This means it allows
developers or writers to work on the same project even if they are
located in different locations.
</p>
<p>
Version control is a means of recording changes to a file or set of
files over time so that you can recall specific versions later.
</p>
<p>
If you prefer watching the tutorial click this
<a
href="https://www.youtube.com/watch?v=9cCApTLb_Io&list=PLbvhRHYrmshSCAHZbibqh_px_LxnU54dk"
>link</a
>
</p>
<h3 id="1-install-git">1. Install Git</h3>
<p>First, you need to install the version control software, Git.</p>
<ul>
<li>Git: Install <a href="https://git-scm.com/downloads">git</a></li>
</ul>
<h3 id="2-checking-status-of-the-repository">
2. Checking status of the repository
</h3>
<p>
The <em>git status</em> command allows you to know the status of the
project: If it is
</p>
<ul>
<li>initiated</li>
<li>modified</li>
<li>staged</li>
</ul>
<p>
We can write the command <em>git status</em> at any time. It is a
means to to check what is happening on your project.
</p>
<h3 id="3-configure-your-name-and-your-email">
3. Configure your name and your email
</h3>
<p>
Open the Git bash if your device is Windows, or open the Mac terminal
if your device is MacOS and then write the following commands
</p>
<pre><code class="lang-shell">git config --global user<span class="hljs-selector-class">.name</span> <span class="hljs-string">'yourname'</span>
git config --global user<span class="hljs-selector-class">.email</span> <span class="hljs-string">'youremail'</span>
</code></pre>
<h3 id="4-create-a-local-git-repository">
4. Create a local git repository
</h3>
<p>
In this step, you will create a folder (directory) for your project. A
project is just a simple folder that stores all the files related to a
certain project. A local repository is a project or a folder that is
on your computer.
</p>
<p>
If your Git bash is not opened, go to start and type git bash. Git
terminal will popup on Windows devices. If it is MasOS just open the
Mac terminal. On the terminal write:
</p>
<pre><code class="lang-shell"><span class="hljs-built_in">mkdir</span> project_name
<span class="hljs-built_in">cd</span> project_name
</code></pre>
<p>
By the way, you can also create the folders the usual way using on the
GUI(Graphical User Interface) of Windows or Mac.
</p>
<h3 id="5-initialize-git">5. Initialize Git</h3>
<p>
After creating a new local repository or in an existing local
repository, initialize the repository by the following command:
</p>
<pre><code class="lang-shell"><span class="hljs-attribute"> git init</span>
</code></pre>
<p>
Once, the repository is initialized git tracks the changes in the
files and folders of the project.
</p>
<h3 id="6-add-file-to-the-staging-area">
6. Add file to the staging area
</h3>
<p>
The file can be added to the staging area in multiple ways. To add a
single file, we use the <em>git add</em> command followed by a file
name
</p>
<pre><code class="lang-shell"> git <span class="hljs-keyword">add</span><span class="bash"> filename</span>
</code></pre>
<p>
To add multiple files using their file names using the command
<em>git add</em> followed by file names
</p>
<pre><code class="lang-shell"> git <span class="hljs-keyword">add</span><span class="bash"> filename1 filename2</span>
</code></pre>
<p>
Sometimes, we may make a lot of changes, and adding files one by one
is tiring and not product. Therefore, we can use a short and product
way. The
<em>git add</em> command followed by a dot allows adding files and
folders at once to the stage area. Remember, there is a space between
the add and the dot.
</p>
<p>To add all files and folders at once</p>
<pre><code class="lang-shell"> git <span class="hljs-keyword">add</span><span class="bash"> .</span>
</code></pre>
<h3 id="7-unstage-a-file">7. Unstage a file</h3>
<pre><code class="lang-shell"> git <span class="hljs-keyword">reset</span> <span class="hljs-keyword">HEAD</span> filename
</code></pre>
<h3 id="8-commit-the-changes">8. Commit the changes</h3>
<p>
Commit means taking a snapshot or a copy of your file at that point in
time. You may associate it with saving a file with a new name (save
as).
</p>
<pre><code class="lang-shell"> <span class="hljs-attribute">git</span> commit -m <span class="hljs-string">'your message'</span>
</code></pre>
<p>
Your commit message has to be associated with the changes or
modifications you make.
</p>
<h3 id="9-git-log">9. Git log</h3>
<p>
The <em>git log</em> command allows knowing the commit history of the
project
</p>
<h3 id="10-git-check-out">10. Git check out</h3>
<p>
We can identify the commit id of each commit using the
<em>git log</em> command. Then we can make use of this id to retire
any previous commit.
</p>
<pre><code class="lang-sh">git checkout <span class="hljs-keyword">commit</span>-<span class="hljs-keyword">id</span>
</code></pre>
<h3 id="11-creating-a-branch">11. Creating a branch</h3>
<p>
You can create a copy of the master using a branch. You built an
awesome application. You like to keep this awesome application as it
is but you like to add some features. This is the time, you need
branching the master. The branch is the copy of the master at
branching instant. After branching, the branch and the master
don't see each other. You can create as many branches as you want.
</p>
<p>To create a branch:</p>
<ul>
<li>Only to create branch</li>
</ul>
<pre><code class="lang-shell"> git checkout branch-<span class="hljs-built_in">name</span>
</code></pre>
<p>To create branch:</p>
<ul>
<li>To create and checkout to the branch at the same time:</li>
</ul>
<pre><code class="lang-shell"> git checkout -<span class="hljs-selector-tag">b</span> branch-name
</code></pre>
<p>To switch between branches:</p>
<pre><code class="lang-shell"> git checkout main
git checkout branch-<span class="hljs-built_in">name</span>
</code></pre>
<p>To list down all the branches:</p>
<pre><code class="lang-shell"><span class="hljs-attribute"> git branch</span>
</code></pre>
<h3 id="12-create-account-on-github">12. Create account on GitHub</h3>
<p>
Now, create an account on GitHub and sign in using your emails and
password
</p>
<ul>
<li>GitHub Sign up on <a href="https://github.com/">GitHub</a></li>
</ul>
<h3 id="13-create-repository-on-github">
13. Create Repository on GitHub
</h3>
<p>
Go to <a href="https://github.com/">GitHub</a> and create a repository
by click the plus icon on the top right corner.
</p>
<h3 id="14-connecting-git-with-remote-repository">
14. Connecting git with remote repository
</h3>
<p>
In this step, you will connect your local git repository with your
remote GitHub repository
</p>
<pre><code class="lang-shell"> git remote <span class="hljs-keyword">add</span><span class="bash"> origin remote_repository_ul</span>
</code></pre>
<p>
The word origin could be any word. It is a means to assign the
repository URL. If this is step is passed without error, you are ready
to push it to your remote GitHub repository. Push means actually
uploading what you have on your local to remote repository.
</p>
<h3 id="15-push">15. Push</h3>
<p>
Before you push(upload), please commits any changes and if it is ready
push your files to your remote GitHub repository using the following
command.
</p>
<pre><code class="lang-shell"> git <span class="hljs-built_in">push</span> -u <span class="hljs-built_in">origin</span> master
</code></pre>
<h3 id="16-merge">16. Merge</h3>
<p>
When you work on an individual project or a team project you may have
different branches. Mostly you will have a master(main), develop and
other branches. Then you will merge other branches to your develop and
your develop to master. It is possible to merge any branches. For
instance, lets merge feature branch to develop
</p>
<pre><code class="lang-shell"> git checkout develop
git <span class="hljs-keyword">merge</span> feature
</code></pre>
<p>
Using the above code, now the develop and feature branches do have the
same content
</p>
<h3 id="17-pull">17. Pull</h3>
<p>
If your team merges new features to the develop, then you will be
behind, now you need to make your project to the current stage by
pulling from develop
</p>
<pre><code class="lang-shell"><span class="hljs-attribute"> git checkout yourbranch
git pull origin develop</span>
</code></pre>
<pre><code class="lang-sh"> git checkout develop
git merge yourbranch
git <span class="hljs-built_in">push</span> -u <span class="hljs-built_in">origin</span> develop
</code></pre>
<p>
If you are a sole developer that works by yourself then you can test
the
<em>git pull</em> command by modifying some of the files from your
remote repository and pull it using the <em>git pull</em> command.
</p>
<h3 id="18-git-clone">18. Git clone</h3>
<p>
GitHub allows downloading a project using a URL. It is the same as
downloading by clicking a download button from a website. To clone, go
to desktop or any location and write the command
<em>git clone URL</em>.
</p>
<p>
For instance, to clone this repository, you need to run the following
command
</p>
<pre><code class="lang-sh">Asabeneh<span class="hljs-variable">@DESKTOP</span>-KGC1AKC MINGW64 ~<span class="hljs-variable">$ </span>cd Desktop
Asabeneh<span class="hljs-variable">@DESKTOP</span>-KGC1AKC MINGW64 ~<span class="hljs-regexp">/Desktop$ git clone https:/</span><span class="hljs-regexp">/github.com/</span>Asabeneh/<span class="hljs-number">10</span>-days-of-git-<span class="hljs-keyword">and</span>-github.git
</code></pre>
<h3 id="19-rename-branch">19. Rename Branch</h3>
<p>To rename a current branch</p>
<pre><code class="lang-sh">git branch -m <<span class="hljs-keyword">new</span><span class="hljs-type">name</span>>
</code></pre>
<p>To rename any branch</p>
<pre><code class="lang-sh">git branch -m <span class="hljs-tag"><<span class="hljs-name">oldname</span>></span> <span class="hljs-tag"><<span class="hljs-name">newname</span>></span>
</code></pre>
<h3 id="20-deleting-branch">20. Deleting Branch</h3>
<p>To delete a local branch</p>
<pre><code class="lang-sh"><span class="hljs-symbol">git</span> <span class="hljs-keyword">branch </span>-d <span class="hljs-keyword">branch-name
</span><span class="hljs-symbol">git</span> <span class="hljs-keyword">branch </span>-D <span class="hljs-keyword">branch-name</span>
</code></pre>
<p>To delete a remote branch</p>
<pre><code class="lang-sh">git push <remote_name> <span class="hljs-symbol">:<branch_name></span>
</code></pre>
<p>or</p>
<pre><code class="lang-sh">git push <span class="hljs-symbol"><remote_name></span> --<span class="hljs-keyword">delete</span> <span class="hljs-symbol"><branch_name></span>
</code></pre>
<h3 id="21-the-gitignore-file">21. The .gitignore file</h3>
<p>Any file you committed could be pushed to a remote repository but sometimes you may not want to push everything you have on your local repository. For instance sensitive data such as email, password, bank account, API Keys and others. Therefore, any files or folders that is listed on the .ignore file will not be tracked by Git. Create a .ignore file on the top level of your project directory, on this file put file names or folder you would like to ignore</p>
<p>The .ignore file</p>
<pre><code class="lang-sh"><span class="hljs-keyword">test
</span>personal-data
example.txt
sensitive-info.txt
</code></pre>
<p>
<em
>Congratulations! Now, you have a solid foundation of Git and
GitHub</em
>
</p>
<h2 id="git-cheat-sheet-">Git cheat sheet:</h2>
<p>Here you have the basic git commands which might be useful:</p>
<pre><code class="lang-shell">git <span class="hljs-comment">--version // to check the version</span>
git <span class="hljs-keyword">help</span> // <span class="hljs-keyword">To</span> <span class="hljs-keyword">get</span> <span class="hljs-keyword">help</span> <span class="hljs-keyword">from</span> git
git <span class="hljs-keyword">help</span> <span class="hljs-keyword">commit</span> // <span class="hljs-keyword">To</span> <span class="hljs-keyword">get</span> <span class="hljs-keyword">commit</span> <span class="hljs-keyword">help</span>
git init // Initilaizing git repository <span class="hljs-keyword">on</span> <span class="hljs-keyword">local</span> machine
git config <span class="hljs-comment">--list // to check what is configured</span>
git config // <span class="hljs-keyword">to</span> <span class="hljs-keyword">get</span> information about configuration
git config <span class="hljs-comment">--global user.name "username" //Configuring git user name</span>
git config <span class="hljs-comment">--global user.email "email" //Configuring git user email</span>
git <span class="hljs-keyword">add</span> filename
git <span class="hljs-keyword">add</span> first.txt # adding <span class="hljs-keyword">only</span> one <span class="hljs-keyword">file</span>
git <span class="hljs-keyword">add</span> second.txt third.txt // <span class="hljs-keyword">to</span> <span class="hljs-keyword">add</span> multiple <span class="hljs-keyword">file</span>
git <span class="hljs-keyword">add</span> . //<span class="hljs-keyword">To</span> <span class="hljs-keyword">add</span> all the files <span class="hljs-keyword">and</span> folders <span class="hljs-keyword">to</span> the staging area
git <span class="hljs-keyword">commit</span> -m <span class="hljs-string">'commit message'</span> // <span class="hljs-keyword">after</span> staging <span class="hljs-keyword">using</span> <span class="hljs-keyword">add</span>
git <span class="hljs-keyword">commit</span> -a -m <span class="hljs-string">'commit message'</span> // staging <span class="hljs-keyword">using</span> a <span class="hljs-keyword">and</span> commiting
git <span class="hljs-keyword">commit</span> -am <span class="hljs-string">'commit message'</span> // staging <span class="hljs-keyword">and</span> committing
git <span class="hljs-keyword">commit</span> -am <span class="hljs-string">"Message"</span> #Grab every thing <span class="hljs-keyword">in</span> the working copy <span class="hljs-keyword">and</span> -a allows <span class="hljs-keyword">to</span> <span class="hljs-keyword">skip</span> the staging copy
git <span class="hljs-keyword">log</span> // <span class="hljs-keyword">To</span> see the history <span class="hljs-keyword">on</span> the repository
git <span class="hljs-keyword">log</span> <span class="hljs-comment">--author ="name" #To check change by specific user</span>
git <span class="hljs-keyword">status</span> //<span class="hljs-keyword">To</span> <span class="hljs-keyword">check</span> changes <span class="hljs-keyword">or</span> <span class="hljs-keyword">status</span> <span class="hljs-keyword">of</span> the <span class="hljs-keyword">file</span>
git diff #Compare workin copy <span class="hljs-keyword">in</span> the repository
git diff <span class="hljs-comment">--staged # Compare files in the staging area</span>
git rm filename
git mv filename1 filename2
git mv filename foldernam/filename2
git <span class="hljs-keyword">commit</span> -am <span class="hljs-string">"This skip the stage process"</span>
git checkout <span class="hljs-comment">-- filename #To get working copy back</span>
git <span class="hljs-keyword">reset</span> <span class="hljs-keyword">HEAD</span> filename // removes <span class="hljs-keyword">from</span> the staging area/unstage
git checkout <span class="hljs-number">01e7</span>ba <span class="hljs-comment">-- filename # Tracking the differentversion of the project</span>
git remote <span class="hljs-keyword">add</span> anyname repositoryUrl
git push -u remote <span class="hljs-keyword">master</span> // <span class="hljs-keyword">to</span> push the <span class="hljs-keyword">file</span> <span class="hljs-keyword">into</span> github
git checkout <span class="hljs-number">01e7</span>ba <span class="hljs-comment">-- filename</span>
git remote <span class="hljs-keyword">add</span> anyname repositoryUrl
</code></pre>
<h1 id="day-3">Day 3</h1>
<h2 id="git-repository-user-interface-features">
Git repository user interface features
</h2>
<p>
Familiarize yourself to GitHub account and repository available
features. Git has account setting and repository setting. Navigate
through the available features.
</p>
<p>Check the available repository features by clicking each buttons.</p>
<p><img src="./images/github-repository-ui_1.png" alt="" /></p>
<p>Check what is available on your GitHub account settings</p>
<p><img src="./images/github-repository-ui_2.png" alt="" /></p>
<h1 id="day-4">Day 4</h1>
<h2 id="github-page">GitHub page</h2>
<p>
Every GitHub repository allows you to generate a URL of your project.
For instance, this
<a href="https://asabeneh.github.io/10-days-of-git-and-github/"
>URL</a
>
has been generated from this project GitHub page. To generate GitHub
page URL, you should have an index.html at the top level inside the
project.
</p>
<p>
First go to the setting of this repository and then click on it. Go
all the way down until you get the GitHub pages section, then select
the master <img src="./images/github-page.png" alt="" />
</p>
<p>
After you select the master, a save button will appear and click save.
</p>
<p><img src="./images/github-page-save.png" alt="" /></p>
<p>
After saving, a GitHub page URL will be generated automatically. That
is your URL for that specific project.
</p>
<p><img src="./images/github-page-link.png" alt="" /></p>
<h1 id="day-5">Day 5</h1>
<h2 id="documenting-on-github">Documenting on GitHub</h2>
<h2 id="github-markdown">GitHub Markdown</h2>
<p>