-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
445 lines (435 loc) · 14.8 KB
/
index.html
File metadata and controls
445 lines (435 loc) · 14.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="shortcut icon"
href="https://git-scm.com/images/logos/logomark-orange@2x.png"
type="image/x-icon"
/>
<!-- Google Font -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=Jost:ital,wght@0,100..900;1,100..900&display=swap"
rel="stylesheet"
/>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- font awesome cdn -->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css"
integrity="sha512-Evv84Mr4kqVGRNSgIGL/F/aIDqQb7xQ2vcrdIwxfjThSH8CSR7PBEakCr51Ck+w+/U6swU2Im1vVX0SVk9ABhg=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<style>
.serif {
font-family: "DM Serif Display", serif;
}
.jost {
font-family: "Jost", sans-serif;
}
</style>
<title>git Tutorial</title>
</head>
<body>
<main class="container max-w-screen-md mx-auto py-5 px-3">
<section>
<div class="flex justify-center items-center border-b-2 pb-3">
<img
class="w-[10%]"
src="https://git-scm.com/images/logos/logomark-orange@2x.png"
alt="git"
/>
<h1 class="text-2xl serif px-3 capitalize md:text-4xl">
git tutorial from scratch to expert:
</h1>
</div>
</section>
<!-- git intro -->
<section class="py-5">
<div class="">
<h2 class="text-3xl serif my-2">🚀 What is Git?</h2>
<p class="jost text-xl">
Git is a version control system that developers use to track changes
in code and collaborate with others on software projects.
</p>
</div>
</section>
<!-- Installation of git -->
<section>
<div>
<div class="flex space-x-5">
<div class="w-10 h-10 bg-green-500 rounded-full">
<!-- -->
</div>
<div>
<h2 class="serif text-2xl md:text-3xl lg:text-4xl py-2">
getting started: installation
</h2>
</div>
</div>
<div class="border-b-2 py-3">
<ul>
<li class="jost font-semibold text-2xl list-disc">
Windows/Mac/Linus:
</li>
</ul>
<a
class="underline jost text-xl"
href="https://git-scm.com/downloads"
target="_blank"
>Download Git</a
>
<ul>
<li class="jost font-semibold text-2xl list-disc">
Verify Installation:
</li>
<p class="bg-red-50 p-3 rounded-md jost">git --version</p>
</ul>
</div>
</div>
</section>
<!-- basic concept -->
<section class="py-5">
<div>
<h2 class="capitalize text-3xl serif mt-2">🧾 basic concept</h2>
</div>
<div class="border-b-2 py-2">
<ul class="list-disc text-xl">
<li class="jost my-2">
<span class="serif">Repository (Repo):</span> Directory tracked by
Git
</li>
<li class="jost my-2">
<span class="serif">Commit: </span>A snapshot of your code
</li>
<li class="jost my-2">
<span class="serif">Branch:</span> Independent line of development
</li>
<li class="jost my-2">
<span class="serif">Clone: </span>Copy of a repository from remote
to local
</li>
</ul>
</div>
</section>
<!-- Step-by-Step Basic Usage -->
<section class="py-5">
<div>
<div>
<h2 class="serif text-2xl md:text-3xl lg:text-4xl py-2">
🔶 Step-by-Step Basic Usage
</h2>
</div>
<div class="grid grid-cols-1">
<div class="my-1">
<h3 class="jost text-xl">1️⃣ Initialize Repository</h3>
<p class="bg-red-50 p-3 rounded-md jost">git init</p>
</div>
<div class="my-1">
<h3 class="jost text-xl">2️⃣ Add Files</h3>
<p class="bg-red-50 p-3 rounded-md jost">
git add <i>file_name</i>
</p>
</div>
<div class="my-1">
<h3 class="jost text-xl">3️⃣ Commit Changes</h3>
<p class="bg-red-50 p-3 rounded-md jost">
Changes git commit -m "initial commit"
</p>
</div>
<div class="my-1">
<h3 class="jost text-xl">4️⃣ Check Status</h3>
<p class="bg-red-50 p-3 rounded-md jost">git status</p>
</div>
<div class="my-1">
<h3 class="jost text-xl">5️⃣ View Commit History</h3>
<p class="bg-red-50 p-3 rounded-md jost">git log</p>
</div>
<div class="my-1">
<h3 class="jost text-xl">6️⃣ Set Git Identity</h3>
<p>
<li class="bg-red-50 p-1 rounded-md jost">
git config --global user.name "Your Name"
</li>
<li class="bg-red-50 p-1 rounded-md jost">
git config --global user.email "your.email@example.com
</li>
</p>
</div>
</div>
</div>
</section>
<!-- Working with Remote Repositories (GitHub, GitLab) -->
<section class="py-5">
<div>
<h2 class="serif text-2xl md:text-3xl lg:text-4xl py-2">
🌍 Working with Remote Repositories (GitHub, GitLab)
</h2>
</div>
<div>
<div class="my-1">
<h3 class="jost text-xl">Clone Remote Repository</h3>
<p class="bg-red-50 p-3 rounded-md jost">
git clone <i>repository_URL</i>
</p>
</div>
<div class="my-1">
<h3 class="jost text-xl">Push Changes</h3>
<p class="bg-red-50 p-3 rounded-md jost">
git push origin <i>branch_name</i>
</p>
</div>
<div class="my-1">
<h3 class="jost text-xl">Pull Updates</h3>
<p class="bg-red-50 p-3 rounded-md jost">
git pull origin <i>branch_name</i>
</p>
</div>
</div>
</section>
<section>
<div>
<div>
<h2 class="serif text-2xl md:text-3xl lg:text-4xl py-2">
🌳 Branching and Merging
</h2>
</div>
<div class="my-1">
<h3 class="jost text-xl">Create New Branch</h3>
<p class="bg-red-50 p-3 rounded-md jost">
git branch <i>branch_name</i>
</p>
</div>
<div class="my-1">
<h3 class="jost text-xl">Switch Branches</h3>
<p class="bg-red-50 p-3 rounded-md jost">
git checkout <i>branch_name</i>
</p>
</div>
<div class="my-1">
<h3 class="jost text-xl">Create and Switch</h3>
<p class="bg-red-50 p-3 rounded-md jost">
git checkout -b <i>branch_name</i>
</p>
</div>
<div class="my-1">
<h3 class="jost text-xl">Merge Branches</h3>
<p class="bg-red-50 p-3 rounded-md jost">
git merge <i>branch_name</i>
</p>
</div>
<div class="my-1">
<h3 class="jost text-xl">Delete Branch</h3>
<p class="bg-red-50 p-3 rounded-md jost">
git branch -d <i>branch_name</i>
</p>
</div>
</div>
</section>
<!-- Resolving Conflicts -->
<section class="py-5">
<div>
<h2 class="serif text-2xl md:text-3xl lg:text-4xl py-2">
✂️ Resolving Conflicts
</h2>
</div>
<div>
<ul>
<li class="list-disc jost">
If merging causes conflicts, Git will indicate it.
</li>
<li class="list-disc jost">Resolve manually, then:</li>
</ul>
<p class="bg-red-50 p-3 rounded-md jost">
git add <i>resolved_file</i>
</p>
<p class="bg-red-50 p-3 rounded-md jost mt-2 jost">
git commit -m "Resolved conflict"
</p>
</div>
</section>
<!-- Undoing Changes -->
<section class="py-5">
<div>
<h2 class="serif text-2xl md:text-3xl lg:text-4xl py-2">
🔁 Undoing Changes
</h2>
</div>
<div>
<li class="list-disc jost text-xl my-2">
Undo last commit (keep changes):
</li>
<p class="bg-red-50 p-3 rounded-md jost mt-2 jost">
git reset --soft HEAD~1
</p>
</div>
<div>
<li class="list-disc jost text-xl my-2">Discard unstaged changes:</li>
<p class="bg-red-50 p-3 rounded-md jost mt-2 jost">
git checkout -- <i>file_name</i>
</p>
</div>
</section>
<!-- Advanced Git Usage -->
<section>
<div>
<h2 class="serif text-2xl md:text-3xl lg:text-4xl py-2">
🙎♂️ Advanced Git Usage
</h2>
</div>
<div>
<h2 class="jost text-xl">1️⃣ Stashing Changes</h2>
<p class="bg-red-50 p-3 rounded-md jost mt-2 jost">
git stash <br />git stash pop
</p>
</div>
<div>
<h2 class="jost text-xl">2️⃣ Rebase</h2>
<p class="rounded-md jost jost">Rewrite commit history:</p>
<p class="bg-red-50 p-3 rounded-md jost mt-2 jost">
git checkout feature_branch <br />
git rebase main
</p>
</div>
<div>
<h2 class="jost text-xl">3️⃣ Cherry-Pick</h2>
<p class="rounded-md jost jost">
Apply a specific commit from one branch to another:
</p>
<p class="bg-red-50 p-3 rounded-md jost mt-2 jost">
git cherry-pick <i>commit_hash</i>
</p>
</div>
<div>
<h2 class="jost text-xl">4️⃣ Tagging</h2>
<p class="rounded-md jost jost">Create tags to mark versions:</p>
<p class="bg-red-50 p-3 rounded-md jost mt-2 jost">
git tag -a v1.0 -m "version 1.0 release" <br />
git push --tags
</p>
</div>
<div>
<h2 class="jost text-xl">5️⃣ Amend Commit</h2>
<p class="rounded-md jost jost">
Modify last commit message or content:
</p>
<p class="bg-red-50 p-3 rounded-md jost mt-2 jost">
git commit --amend -m "New commit message"
</p>
</div>
</section>
<!-- Cleaning Repository -->
<section>
<div>
<h2 class="serif text-2xl md:text-3xl lg:text-4xl py-2">
🧹 Cleaning Repository
</h2>
</div>
<div>
<li class="list-disc jost text-xl my-2">Remove untracked files:</li>
<p class="bg-red-50 p-3 rounded-md jost mt-2 jost">git clean -f</p>
</div>
<div>
<li class="list-disc jost text-xl my-2">
Remove untracked directories too:
</li>
<p class="bg-red-50 p-3 rounded-md jost mt-2 jost">git clean -fd</p>
</div>
</section>
<!-- best practice -->
<section class="py-5">
<div>
<h2 class="serif text-2xl md:text-3xl lg:text-4xl py-2">
📚 Best Practices
</h2>
<ul>
<li class="list-disc jost text-xl my-2">
Write meaningful commit messages.
</li>
<li class="list-disc jost text-xl my-2">Commit often.</li>
<li class="list-disc jost text-xl my-2">
Keep branches small and focused.
</li>
<li class="list-disc jost text-xl my-2">
Regularly sync branches with main.
</li>
</ul>
</div>
</section>
<section class="py-5">
<div>
<h2 class="serif text-2xl md:text-3xl lg:text-4xl py-2">
🔥 Git Expert Commands & Workflow
</h2>
</div>
<div>
<h2 class="jost text-xl">1️⃣ Interactive Rebase</h2>
<p class="rounded-md jost jost">
Squash commits, reorder, or edit history:
</p>
<p class="bg-red-50 p-3 rounded-md jost mt-2 jost">
git rebase -i HEAD~3
</p>
</div>
<div>
<h2 class="jost text-xl">2️⃣ Submodules</h2>
<p class="rounded-md jost jost">
Include external repositories within your repo:
</p>
<p class="bg-red-50 p-3 rounded-md jost mt-2 jost">
git submodule add <i>repo_url</i> <br />
git submodule update --init --recursive
</p>
</div>
<div>
<h2 class="jost text-xl">3️⃣ Bisect (Finding Bugs)</h2>
<p class="rounded-md jost jost">Identify the commit causing a bug:</p>
<p class="bg-red-50 p-3 rounded-md jost mt-2 jost">
git bisect start <br />
git bisect bad <br />
git bisect good <i>good_commit_hash</i>
</p>
</div>
<div>
<h2 class="jost text-xl">4️⃣ Aliases</h2>
<p class="rounded-md jost jost">Create shortcuts for commands:</p>
<p class="bg-red-50 p-3 rounded-md jost mt-2 jost">
git config --global alias.st "status"
</p>
</div>
<div>
<h2 class="jost text-xl">5️⃣ Hooks</h2>
<p class="rounded-md jost jost">
Run scripts automatically at specific points:
</p>
<li class="list-disc jost text-xl my-2">pre-commit</li>
<li class="list-disc jost text-xl my-2">commit-msg</li>
<li class="list-disc jost text-xl my-2">pre-push</li>
<p>
<i class="jost py-1"
>(Create custom scripts in .git/hooks/ directory.)</i
>
</p>
</div>
</section>
<section class="px-5 flex justify-center items-center">
<div class="md:flex">
<!-- -->
<h2 class="serif px-1">Documentation</h2>
<a
class="jost underline"
href="https://git-scm.com/doc"
target="_blank"
href=""
>For Official Documentation</a
>
</div>
</section>
</main>
</body>
</html>