forked from EshanTrivedi21/Git-CheatSheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1358 lines (1286 loc) · 56.7 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 http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" href="./ASSETS/favicon.png" type="image/x-icon" />
<title>Git-CheatSheet</title>
<link rel="stylesheet" href="./ASSETS/styles.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://kit.fontawesome.com/d4705f63a2.js" crossorigin="anonymous"></script>
</head>
<body><div class="navbar">
<pre class = "sidebar_pre"><nav id="sidebar"><h3>Git-GITHUB Cheatsheet Topics</h3><hr><ul class="navbar-items">
<li><a href="#terminal-basics">terminal basics</a></li>
<li><a href="#setting-git-user-name-and-email">setting git user name and email</a></li>
<li><a href="#getting-git-help">getting git help</a></li>
<li><a href="#creating-a-git-repository">creating a git repository</a></li>
<li><a href="#staging-filefiles-of-the-repository">staging file/files of the repository</a></li>
<li><a href="#commiting-a-commit">commiting a commit</a></li>
<li><a href="#git-ignore">git ignore</a></li>
<li><a href="#merging-branches">git branching</a></li>
<li><a href="#stashing-git">stashing in git</a></li>
<li><a href="#time-travelling-git">time travelling with git</a></li>
<li><a href="#creating-github-repository">creating github respositories</a></li>
<li><a href="#origin-master-theory">the origin/master theory</a></li>
<li><a href="#pulling-interferes">pulling interferes in the working directory</a></li>
<li><a href="#git-rebasing">git rebasing</a></li>
<li><a href="#git-tags">git tags</a></li>
<li><a href="#github-desktop">github desktop</a></li>
<li><a href="#github-extensions">extensions for Github</a></li>
<li><a href="#download-pdf">download git-github cheatsheet</a></li>
</ul></nav></pre>
</div>
<div class="topnav">
<pre class="hamburger "><div class = "non_coll"><h4>Git-GITHUB Cheatsheet Topics</h4><a href="javascript:void(0);" class="icon" onclick="myFunction()"> <i class="fa fa-bars fa-lg"></i></a></div><div id="myLinks" class = ""><ul class="navbar-items"><li><a href="#terminal-basics">terminal basics</a></li>
<li><a href="#setting-git-user-name-and-email">setting git user name and email</a></li>
<li><a href="#getting-git-help">getting git help</a></li>
<li><a href="#creating-a-git-repository">creating a git repository</a></li>
<li><a href="#staging-filefiles-of-the-repository">staging file/files of the repository</a></li>
<li><a href="#commiting-a-commit">commiting a commit</a></li>
<li><a href="#git-ignore">git ignore</a></li>
<li><a href="#merging-branches">git branching</a></li>
<li><a href="#stashing-git">stashing in git</a></li>
<li><a href="#time-travelling-git">time travelling with git</a></li>
<li><a href="#creating-github-repository">creating github respositories</a></li>
<li><a href="#origin-master-theory">the origin/master theory</a></li>
<li><a href="#pulling-interferes">pulling interferes in the working directory</a></li>
<li><a href="#git-rebasing">git rebasing</a></li>
<li><a href="#git-tags">git tags</a></li>
<li><a href="#github-desktop">github desktop</a></li>
<li><a href="#github-extensions">extensions for Github</a></li>
<li><a href="#download-pdf">download git-github cheatsheet</a></li></ul></div></pre>
</div>
<div class="container_app">
<input type="checkbox" id="toggle-btn">
<label for="toggle-btn" class="toggle-darkmode">
<i class="fa-solid fa-sun sun-icon" id="icon" alt="Enable the light mode."></i>
<i class="fa-solid fa-moon moon-icon" id="icon" alt="Enable the dark mode."></i>
</label>
</div>
<section class="cheatsheet">
<h1 id="welcome-to-the-git-cheat-sheet">
WELCOME TO THE GIT CHEAT SHEET
</h1>
<br />
<pre><code>TOPIC: GIT-GITHUB CHEATSHEET <br>
DESCRIPTION: Your very own Git and Github Cheatsheet! <br>
REFERENCE: Git-Github Bootcamp (Colt Steele) - Udemy <br>
AUTHORs: <a href="https://github.com/EshanTrivedi21" target="_blank">EshanTrivedi21</a>, <a href="https://github.com/VinayKanase" target="_blank">VinayKanase</a> and <a href="https://github.com/Aryan-Parmar" target="_blank">Aryan-Parmar</a> <br>
REPOSITORY: <a href="https://github.com/EshanTrivedi21/Git-CheatSheet" target="_blank">https://github.com/EshanTrivedi21/Git-CheatSheet</a> <br>
<span class="contributors">CONTRIBUTORS:
<a href="https://github.com/eshantrivedi21/git-cheatsheet/graphs/contributors">
<img class="img"src="https://contrib.rocks/image?repo=eshantrivedi21/git-cheatsheet&columns=14" />
</a>
</span>
</code></pre>
<div class="searchbar">
</div>
<div id="searchElement">
<input id="searchbar" onkeyup="search()" type="text" name="search" placeholder="Search Commands ...">
</div>
<!-- input tag -->
<div id="list_search">
<h2 id="terminal-basics" class="searchItem">TERMINAL BASICS</h2>
<div class="searchItem">
<p><strong>It is the LIST command which LISTS all the contents of a Directory</strong></p>
<code class="language-bash">
<pre>$ ls</pre>
<button class="copy-btn">
<img id="icon" src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>LOCATES to a directory and then LISTS the contents</strong></p>
<code class="language-bash">
<pre>$ ls foldername</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>PRINT WORKING DIRECTORY</strong></p>
<code class="language-bash">
<pre>$ pwd</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p>
<strong>CHANGES and HOPS onto the respective Working Directory</strong>
</p>
<code class="language-bash">
<pre>$ cd C:\User\username\foldername</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>HOPS onto Parent Directory of the Working Directory</strong></p>
<code class="language-bash">
<pre>$ cd ..</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>CLEARS the used Terminal</strong></p>
<code class="language-bash">
<pre>$ clear</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>QUITS out of a entered command</strong></p>
<code class="language-bash">
<pre>$ q</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p>
<strong>CREATES an Empty directory inside the Working Directory</strong>
</p>
<code class="language-bash">
<pre>$ mkdir foldername</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>DELETES the file</strong></p>
<code class="language-bash">
<pre>$ rm filename</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>DELETES the directory</strong></p>
<code class="language-bash">
<pre>$ rm -rf foldername</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>OPENS the File Explorer to the ROOT Directory</strong></p>
<code class="language-bash">
<pre>$ start .</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<h2 id="setting-git-user-name-and-email" class="searchItem">SETTING GIT USER NAME AND EMAIL</h2>
<div class="searchItem">
<p><strong>To CHECK if git User-Name is set</strong></p>
<code class="language-bash">
<pre>$ git config user.name</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>To CHECK if git User-Email is set</strong></p>
<code class="language-bash">
<pre>$ git config user.email</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>To SET or CHANGE git User-Name</strong></p>
<code class="language-bash">
<pre>$ git config --global user.name "Name Lastname"</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>To SET or CHANGE git User-Email</strong></p>
<code class="language-bash">
<pre>$ git config --global user.email "email"</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>To SET or CHANGE default code editor as VSCode</strong></p>
<code class="language-bash">
<pre>$ git config --global core.editor "code --wait"</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>To CHANGE git User-Name and git User-Email directly in the config file using vim</strong></p>
<code class="language-bash">
<pre>$ git config --global --edit</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p>
<strong>To Store git User-Name and git User-Email in disk</strong>
</p>
<code class="language-bash">
<pre>$ git config credential.helper store</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>To exit vim</strong></p>
<code class="language-bash">
<pre>$ escape key + :wq</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<h2 id="getting-git-help" class="searchItem">GETTING GIT HELP</h2>
<div class="searchItem">
<p><strong>Use for more details and examples on any of the below (or above) commands</strong></p>
<code class="language-bash">
<pre>$ git command --help</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<h2 id="creating-a-git-repository" class="searchItem">CREATING A GIT REPOSITORY</h2>
<div class="searchItem">
<p><strong>STEP 1: INITIALIZES an empty repository</strong></p>
<code class="language-bash">
<pre>$ git init</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>STEP 2: to CHECK the status of a repository</strong></p>
<code class="language-bash">
<pre>$ git status</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<h2 id="staging-filefiles-of-the-repository" class="searchItem">STAGING FILE/FILES OF THE REPOSITORY</h2>
<div class="searchItem">
<p><strong>STAGES the file</strong></p>
<code class="language-bash">
<pre>$ git add filename.txt</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>UN-STAGES the file</strong></p>
<code class="language-bash">
<pre>$ git rm --cached filename.txt</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>STAGES all files in the repository</strong></p>
<code class="language-bash">
<pre>
$ git add --all
OR
$ git all .
OR
$ git add .
</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<h2 id="commiting-a-commit" class="searchItem">COMMITING A COMMIT</h2>
<div class="searchItem">
<p><strong>COMMITS the STAGED files with a commit message</strong></p>
<code class="language-bash">
<pre>$ git commit -m "commit message"</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>SKIPS the Staging part and directly COMMITS</strong></p>
<code class="language-bash">
<pre>$ git commit -a -m "commit message"</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>LOGS all the commits done to the repository</strong></p>
<code class="language-bash">
<pre>$ git log</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>LOG commits in a single line</strong></p>
<code class="language-bash">
<pre>$ git log --oneline</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>AMMENDS the previous commit</strong></p>
<code class="language-bash">
<pre>$ git commit --ammend</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>LOGS the changes</strong></p>
<code class="language-bash">
<pre>$ git diff</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<h2 id="git-branching" class="searchItem">GIT BRANCHING</h2>
<div class="searchItem">
<p><strong>LOGS all the branches of the Working Repository</strong></p>
<code class="language-bash">
<pre>$ git branch</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>CREATES a new branch</strong></p>
<code class="language-bash">
<pre>$ git branch <new-branch></pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>SWITCHES the Branch from one to another or CHANGING HEAD</strong></p>
<code class="language-bash">
<pre>$ git switch <new-branch></pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>CREATES a new branch and then SWITCHES to the branches</strong></p>
<code class="language-bash">
<pre>$ git switch -c <new-branch></pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>CREATES a new branch and then SWITCHES to the branch</strong></p>
<code class="language-bash">
<pre>$ git checkout -b <new-branch></pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>DELETES newbranch</strong></p>
<code class="language-bash">
<pre>$ git branch -D <new-branch></pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>CHANGES the name of the Branch you are Headed on</strong></p>
<code class="language-bash">
<pre>$ git branch -M <final-branch></pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>TO DELETE A REMOTE BRANCH IN GIT</strong></p>
<code class="language-bash">
<pre>$ git push --delete <origin branchname></pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<h2 id="git-ignore" class="searchItem">GIT IGNORE</h2>
<div class="searchItem">
<p><strong>STEP 1: create a .gitignore file</strong></p>
</div>
<div class="searchItem">
<p><strong>STEP 2: add files or folders inside the file to ignore, now the files are are untracked by github and
wont be staged or
commited</strong></p>
</div>
<h2 id="git-ignore" class="searchItem">GIT IGNORE PATTERNS</h2>
<div class="searchItem">
<p><strong>Preventing unintentional staging or commiting of files</strong></p>
<code class="language-bash">
<pre>logs/ // ignoring all files inside logs folder<br/>*.notes // ignoring all files with .notes file extension<br/>pattern*/ // ignoring all pattern* files or folders</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<h2 id="merging-branches" class="searchItem">MERGING BRANCHES</h2>
<div class="searchItem">
<h3>FAST FORWARD MERGE</h3>
<p><strong>STEP 1: SWITCH the HEAD first to the first branch</strong></p>
<code class="language-bash">
<pre>$ git switch master</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<p><strong>STEP 2: MERGES newbranch into master with HEAD on master</strong></p>
<code class="language-bash">
<pre>$ git merge <new-branch></pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<h3>NOT ALL MERGES ARE FAST FORWARD MERGES</h3>
<h4>WITH OUT MERGE CONFLICTS</h4>
<code class="language-bash">
<pre>$ git switch master</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<p><strong>CREATES a new commit unlike fastforwarding merges</strong></p>
<code class="language-bash">
<pre>$ git merge -m "mergering message"</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<h4>MERGE CONFLICTS</h4>
<p><strong>STEP 1: OPEN UP files having merge conflicts</strong></p>
<p><strong>STEP 2: REMOVE the conflicts</strong></p>
<p><strong> OPTION 1: ACCEPT INCOMING CHANGES</strong></p>
<p><strong> OPTION 2: ACCEPT CURRENT CHANGES</strong></p>
<p><strong> OPTION 3: ACCEPT BOTH CHANGES</strong></p>
<p><strong> OPTION 4: COMPARE CHANGES</strong></p>
<p><strong>STEP 3: REMOVE the conflict markers</strong></p>
<p><strong>STEP 4: STAGE and COMMIT the changes</strong></p>
<h4>ABORT MERGE WHEN UNRESOLVABLE CONFLICTS OCCURRED</h4>
<code class="language-bash">
<pre>$ git merge --abort</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<h2 id="stashing-git" class="searchItem">STASHING IN GIT</h2>
<div class="searchItem">
<h3>1. CHANGES WILL EITHER COME IN THE DESTINATION BRANCH</h3>
</div>
<div class="searchItem">
<h3>2. GIT WONT ALLOW SWITCHING IF THERE ARE CONFLICTS</h3>
<p><strong>STASHES the changes</strong></p>
<code class="language-bash">
<pre>$ git stash</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<p><strong>UN STASHES the changes, use it when you resume your work</strong></p>
<code class="language-bash">
<pre>$ git stash pop</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<p><strong>APPLY stashed changes into another or the same branch</strong></p>
<code class="language-bash">
<pre>$ git stash apply</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<h4>IF WORKING WITH MULTIPLE STASHES</h4>
<p><strong>LOGS all the stashes</strong></p>
<code class="language-bash">
<pre>$ git stash list</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<p><strong>STASHES the changes in the Stash index 1</strong></p>
<code class="language-bash">
<pre>$ git stash apply stash@{1}</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<p><strong>DELETES the stash, p.s. applying the stash doesnt delete it</strong></p>
<code class="language-bash">
<pre>$ git stash drop stash@{1}</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<p><strong>CLEARS the whole stash list</strong></p>
<code class="language-bash">
<pre>$ git stash clear</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<h2 id="time-travelling-git" class="searchItem">TIME TRAVELLING WITH GIT</h2>
<div class="searchItem">
<h3>1. TO JUST CHECK WHAT THE REPOSITORY LOOKED LIKE IN THE COMMIT ID 604a39a</h3>
<p><strong>DETACHES HEAD and attaches it to the commit with the commit id 604a39a, this is not normal because
HEAD
is meant to map
a whole branch and not a specific commit</strong></p>
<code class="language-bash">
<pre>$ git checkout 604a39a</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<p><strong>DETACHES HEAD and ATTACHES it to the previous commit</strong></p>
<code class="language-bash">
<pre>$ git checkout HEAD~1</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<p><strong>RE-ATTACHES HEAD and now the head properly maps onto the master branch</strong></p>
<code class="language-bash">
<pre>$ git switch master</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<h3>2. TO CREATE AND WORK WITH A NEW BRANCH AT COMMIT ID 604a39a</h3>
<code class="language-bash">
<pre>$ git checkout 604a39a</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<p><strong>now the head is perfect where it should have been</strong></p>
<code class="language-bash">
<pre>$ git switch -c <new-branch></pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<h3>3. TO RESTORE ALL CHANGES TO TRACKED FILES</h3>
<code class="language-bash">
<pre>$ git reset origin/main --hard</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<h3>4. TO RESTORE CHANGES OF A PARTICULAR FILE TO THE LAST COMMIT</h3>
<code class="language-bash">
<pre>
$ git checkout HEAD filename.txt
OR
$ git restore filename.txt
</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<h3>5. TO RESTORE CHANGES OF A PARTICULAR FILE TO THE SECOND-LAST COMMIT</h3>
<code class="language-bash">
<pre>$ git restore --source HEAD~1 filename.txt</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<h3>6. UNSTAGE A FILE</h3>
<code class="language-bash">
<pre>$ git restore --unstaged filename.txt</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<h3>7. RESETING THE REPOSITORY TO A PARTICULAR COMMIT</h3>
<p><strong>NOTE: it resets the head to the commit id 604a39a, but it doesnt delete the changes, it like there is
no
commit made
after commit id 604a39a</strong></p>
<code class="language-bash">
<pre>$ git reset 604a39a</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<p><strong>LOOSES the commit as well as LOOSES the contents of the commit</strong></p>
<code class="language-bash">
<pre>$ git reset --hard 604a39a</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<h3>8. REVERTING THE REPOSITORY TO A PARTICULAR COMMIT</h3>
<p><strong>REVERTS the changes in that particular commit and CREATES a new commit after reverting changes p.s.
this
helps while
collaboration</strong></p>
<code class="language-bash">
<pre>$ git revert 604a39a</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<h2 id="creating-github-repository" class="searchItem">CREATING GITHUB RESPOSITORIES</h2>
<div class="searchItem">
<h3>1. BUILD A NEW REPOSITORY AND START WORKING FROM SCRATCH (BY REMOTING)</h3>
<p><strong>STEP 1: CREATE A NEW REPOSITORY ON YOUR GITHUB WEBSITE AND COPY THE URL</strong></p>
<p><strong>STEP 2: CREATES an empty git repository</strong></p>
<code class="language-bash">
<pre>$ git init</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<p><strong>STEP 3: WRITE YOUR PIECE OF CODE</strong></p>
<p><strong>STEP 4: a commit is needed to push any files to github</strong></p>
<code class="language-bash">
<pre>$ git commit -a -m "first commit"</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<p><strong>STEP 5: CREATES a new REMOTE DESTINATION for the github repository</strong></p>
<code class="language-bash">
<pre>$ git remote add origin <copied url></pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<p><strong>LOGS out the REMOTE URL if any</strong></p>
<code class="language-bash">
<pre>$ git remote -v</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<p><strong>STEP 6: PUSHES the last commited code to github p.s. the -u is like a setting the origin remote and
master branch as a default
so that we can use just >> git push in future</strong></p>
<code class="language-bash">
<pre>$ git push -u origin <branchname></pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<h3>2. BUILD A NEW REPOSITORY AND START WORKING FROM SCRATCH (BY CLONING)</h3>
<p><strong>STEP 1: CREATE A NEW REPOSITORY ON YOUR GITHUB WEBSITE AND COPY THE URL</strong></p>
<p><strong>STEP 2: CLONES as well as automatically sets the REMOTE DESTINATION</strong></p>
<code class="language-bash">
<pre>$ git clone <copied url></pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<p><strong>STEP 3: WRITE YOUR PIECE OF CODE</strong></p>
<p><strong>STEP 4: a commit is needed to push any files to github</strong></p>
<code class="language-bash">
<pre>$ git commit -a -m "first commit"</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<p><strong>STEP 5: PUSHES the last commited code to github p.s. the -u is like a setting the origin remote and
master branch as a default
so that we can use just >> git push in future</strong></p>
<code class="language-bash">
<pre>$ git push -u origin <branchname></pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<h3>3. CONNECT YOUR PREEXISTING GIT REPOSITORY TO A NEW GITHUB REPOSITORY</h3>
<p><strong>STEP 1: CREATE A NEW REPOSITORY ON YOUR GITHUB WEBSITE AND COPY THE URL</strong></p>
<p><strong>STEP 2: CREATES a new REMOTE DESTINATION for the github repository</strong></p>
<code class="language-bash">
<pre>$ git remote add origin <copied url></pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<p><strong>LOGS out the REMOTE URL if any</strong></p>
<code class="language-bash">
<pre>$ git remote -v</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
<p><strong>STEP 3: PUSHES the last commited code to github p.s. the -u is like a setting the origin remote and
master branch as a default
so that we can use just >> git push in future</strong></p>
<code class="language-bash">
<pre>$ git push -u origin <branchname></pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<h2 id="origin-master-theory" class="searchItem">THE origin/master THEORY</h2>
<div class="searchItem">
<p><strong>origin/master IS CALLED AS A REMOTE TRACKING BRANCH, IT IS A REMOTE BRANCH THAT REPRESENTS OUR LOCAL
BRANCH</strong></p>
<p><strong>LOGS the remote tracking branch</strong></p>
<code class="language-bash">
<pre>$ git branch -r</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>To check out the remote branch code: DETACHES HEAD onto the remote tracking HEAD, in a case where the
local branch is
ahead of the remote branch and not up to date, push to make it up to date</strong></p>
<code class="language-bash">
<pre>$ git checkout origin/master</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>BY DEFAULT ONLY LOCAL MASTER BRANCH IS CONNECTED TO THE REMOTE BRANCH BUT OTHERS NEED TO BE CONNECTED
IN
ORDER TO WORK WITH THEM AND THE SIMPLEST WAY TO DO
SO IS</strong></p>
<p><strong>To check all the branches available</strong></p>
<code class="language-bash">
<pre>$ git branch -r</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>This automatically CONNECTS the two branches and we can freely work on them now</strong></p>
<code class="language-bash">
<pre>$ git switch branchname</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>Now this correctly LOGS all the connected branches</strong></p>
<code class="language-bash">
<pre>$ git branch</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<h2 id="fetching-and-pulling" class="searchItem">FETCHING AND PULLING</h2>
<div class="searchItem">
<p><strong>FETCHING ALLOWS TO GET CHANGES FROM THE GITHUB REMOTE REPOSITORY TO OUR LOCAL GIT REPOSITORY BUT
DOESN'T
CHANGE INTO THE
WORKING DIRECTORY</strong></p>
<p><strong>To receive the new commits</strong></p>
<code class="language-bash">
<pre>$ git fetch</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>CREATES a new branch having the changes but this doesnt interfere in the working directory, the
origin/master now heads
on to this new branch and the master branch would be one branch behind the origin/master</strong></p>
<code class="language-bash">
<pre>
$ git fetch origin
OR
$ git fetch origin branchname
</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>To check out the remote branch code: DETACHES HEAD onto the remote tracking HEAD, in a case where the
local branch is
ahead of the remote branch and not up to date, push to make it up to date</strong></p>
<code class="language-bash">
<pre>$ git checkout origin/master</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<h2 id="pulling-interferes" class="searchItem">PULLING INTERFERES IN THE WORKING DIRECTORY</h2>
<div class="searchItem">
<p><strong>PULLS the changes and merges the changes with the branch you want to OR default</strong></p>
<code class="language-bash">
<pre>
$ git pull origin
OR
$ git push origin branchname
</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>SOLVE MERGE CONFLICTS IF ANY</strong></p>
</div>
<h2 id="force-push-and-pull" class="searchItem">FORCE PUSH AND PULL</h2>
<div class="searchItem">
<p><strong>This will delete your previous commit(s) and push your current one. f signifies force</strong></p>
<code class="language-bash">
<pre>$ git push origin <your-branch-name> -f</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<div class="searchItem">
<p><strong>This is nothing but fetch + rebase. This will invoke rebase in interactive mode where you can choose
how
to apply each
individual commit that isn't in the history you are rebasing on</strong></p>
<code class="language-bash">
<pre>
$ git pull --rebase=interactive
OR
$ git pull --rebase=i
</pre>
<button class="copy-btn">
<img src="./ASSETS/copy-icon.svg" alt="copy" />
</button>
</code>
</div>
<h2 id="github-collaboration" class="searchItem">GITHUB COLLABORATION</h2>
<div class="searchItem">
<p><strong>CENTRALIZED WORKFLOW: EVERY BODY WORKS ON THE SAME MAIN BRANCH AND PUSH AND PULL IN THE MAIN BRANCH
ONLY.</strong></p>
</div>
<div class="searchItem">
<p><strong>FEATURE BRANCH WORKFLOW: EVERY FEATURE IS PUSHED UPON ANOTHER INDEPENDANT BRANCH TO MINIMIZE
MESS</strong></p>
</div>
<div class="searchItem">
<p><strong>GITHUB PULL REQUEST WORKFLOW: Once a pull request is opened, you can discuss and review the potential
changes with
collaborators and add follow-up commits before your changes are merged into the base branch.</strong></p>
</div>
<div class="searchItem">
<p><strong>GITHUB FORKS AND CLONE WORKFLOW: Forking nd then opening a pull request to the owner of the main
repository.</strong></p>
</div>
<h2 id="git-rebasing" class="searchItem">GIT REBASING</h2>
<div class="searchItem">
<h3>REBASES OR SEPARATES THE HISTORY OF THE NEWBRANCH FROM THE MASTER BRANCH</h3>
<code class="language-bash">