-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_tutorial.html
More file actions
687 lines (605 loc) Β· 23.2 KB
/
git_tutorial.html
File metadata and controls
687 lines (605 loc) Β· 23.2 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Git & GitHub Tutorial</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.6;
color: #333;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
header {
text-align: center;
color: white;
margin-bottom: 30px;
}
h1 {
font-size: 3rem;
margin-bottom: 10px;
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}
.subtitle {
font-size: 1.2rem;
opacity: 0.9;
}
.tutorial-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
gap: 25px;
margin-top: 40px;
}
.tutorial-card {
background: white;
border-radius: 15px;
padding: 30px;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.tutorial-card:hover {
transform: translateY(-5px);
box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}
.card-header {
display: flex;
align-items: center;
margin-bottom: 20px;
}
.card-icon {
width: 40px;
height: 40px;
background: linear-gradient(45deg, #667eea, #764ba2);
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
margin-right: 15px;
color: white;
font-size: 1.5rem;
}
.card-title {
font-size: 1.5rem;
color: #333;
font-weight: 600;
}
.command-block {
background: #2d3748;
color: #e2e8f0;
padding: 15px;
border-radius: 8px;
margin: 15px 0;
font-family: 'Courier New', monospace;
position: relative;
overflow-x: auto;
}
.command-block::before {
content: '$ ';
color: #4fd1c7;
font-weight: bold;
}
.copy-btn {
position: absolute;
top: 10px;
right: 10px;
background: #667eea;
color: white;
border: none;
padding: 5px 10px;
border-radius: 5px;
cursor: pointer;
font-size: 0.8rem;
transition: background 0.3s ease;
}
.copy-btn:hover {
background: #5a67d8;
}
.step {
margin: 20px 0;
padding: 15px;
background: #f8f9fa;
border-left: 4px solid #667eea;
border-radius: 5px;
}
.step-number {
display: inline-block;
width: 25px;
height: 25px;
background: #667eea;
color: white;
border-radius: 50%;
text-align: center;
line-height: 25px;
margin-right: 10px;
font-weight: bold;
font-size: 0.9rem;
}
.interactive-demo {
background: #1a202c;
color: #e2e8f0;
padding: 20px;
border-radius: 10px;
margin: 20px 0;
}
.terminal-header {
background: #2d3748;
color: #cbd5e0;
padding: 10px 15px;
border-radius: 8px 8px 0 0;
font-weight: bold;
border-bottom: 2px solid #4a5568;
}
.terminal-content {
background: #1a202c;
padding: 15px;
border-radius: 0 0 8px 8px;
font-family: 'Courier New', monospace;
font-size: 0.9rem;
line-height: 1.4;
}
.git-command {
color: #4fd1c7;
}
.git-output {
color: #68d391;
margin-left: 10px;
}
.warning {
background: #fef5e7;
border: 1px solid #f6ad55;
color: #c05621;
padding: 15px;
border-radius: 8px;
margin: 15px 0;
}
.success {
background: #f0fff4;
border: 1px solid #68d391;
color: #2f855a;
padding: 15px;
border-radius: 8px;
margin: 15px 0;
}
.workflow-diagram {
background: white;
border: 2px solid #e2e8f0;
border-radius: 10px;
padding: 20px;
margin: 20px 0;
text-align: center;
}
.workflow-step {
display: inline-block;
background: #667eea;
color: white;
padding: 10px 20px;
border-radius: 25px;
margin: 5px;
position: relative;
}
.workflow-step::after {
content: 'β';
position: absolute;
right: -20px;
top: 50%;
transform: translateY(-50%);
color: #667eea;
font-weight: bold;
}
.workflow-step:last-child::after {
display: none;
}
.quiz-section {
background: linear-gradient(45deg, #f093fb 0%, #f5576c 100%);
color: white;
padding: 25px;
border-radius: 15px;
margin: 30px 0;
}
.quiz-button {
background: white;
color: #f5576c;
border: none;
padding: 12px 25px;
border-radius: 25px;
cursor: pointer;
font-weight: bold;
margin: 10px 5px;
transition: transform 0.3s ease;
}
.quiz-button:hover {
transform: scale(1.05);
}
.progress-bar {
background: #e2e8f0;
height: 6px;
border-radius: 3px;
margin: 20px 0;
overflow: hidden;
}
.progress-fill {
background: linear-gradient(90deg, #667eea, #764ba2);
height: 100%;
width: 0%;
border-radius: 3px;
transition: width 0.5s ease;
}
@media (max-width: 768px) {
h1 {
font-size: 2rem;
}
.tutorial-grid {
grid-template-columns: 1fr;
}
.container {
padding: 15px;
}
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>π Git & GitHub Mastery</h1>
<p class="subtitle">Complete Interactive Tutorial for Version Control</p>
<div class="progress-bar">
<div class="progress-fill" id="progressBar"></div>
</div>
</header>
<div class="tutorial-grid">
<!-- Git Basics Card -->
<div class="tutorial-card">
<div class="card-header">
<div class="card-icon">π</div>
<h2 class="card-title">Git Basics</h2>
</div>
<div class="step">
<span class="step-number">1</span>
<strong>Install Git</strong>
<p>Download from <a href="https://git-scm.com" target="_blank">git-scm.com</a></p>
</div>
<div class="step">
<span class="step-number">2</span>
<strong>Configure Git</strong>
<div class="command-block">
git config --global user.name "Your Name"
<button class="copy-btn" onclick="copyToClipboard(this)">Copy</button>
</div>
<div class="command-block">
git config --global user.email "your.email@example.com"
<button class="copy-btn" onclick="copyToClipboard(this)">Copy</button>
</div>
</div>
<div class="success">
β
You're now ready to start using Git!
</div>
</div>
<!-- Repository Creation Card -->
<div class="tutorial-card">
<div class="card-header">
<div class="card-icon">π</div>
<h2 class="card-title">Create Repository</h2>
</div>
<div class="step">
<span class="step-number">1</span>
<strong>Initialize a Repository</strong>
<div class="command-block">
git init my-project
<button class="copy-btn" onclick="copyToClipboard(this)">Copy</button>
</div>
</div>
<div class="step">
<span class="step-number">2</span>
<strong>Navigate to Project</strong>
<div class="command-block">
cd my-project
<button class="copy-btn" onclick="copyToClipboard(this)">Copy</button>
</div>
</div>
<div class="interactive-demo">
<div class="terminal-header">Terminal Demo</div>
<div class="terminal-content">
<div class="git-command">$ git init my-awesome-project</div>
<div class="git-output">Initialized empty Git repository in /path/to/my-awesome-project/.git/</div>
</div>
</div>
</div>
<!-- Basic Commands Card -->
<div class="tutorial-card">
<div class="card-header">
<div class="card-icon">β‘</div>
<h2 class="card-title">Essential Commands</h2>
</div>
<div class="step">
<span class="step-number">1</span>
<strong>Check Status</strong>
<div class="command-block">
git status
<button class="copy-btn" onclick="copyToClipboard(this)">Copy</button>
</div>
</div>
<div class="step">
<span class="step-number">2</span>
<strong>Add Files</strong>
<div class="command-block">
git add filename.txt
<button class="copy-btn" onclick="copyToClipboard(this)">Copy</button>
</div>
<div class="command-block">
git add .
<button class="copy-btn" onclick="copyToClipboard(this)">Copy</button>
</div>
</div>
<div class="step">
<span class="step-number">3</span>
<strong>Commit Changes</strong>
<div class="command-block">
git commit -m "Your commit message"
<button class="copy-btn" onclick="copyToClipboard(this)">Copy</button>
</div>
</div>
<div class="workflow-diagram">
<h4>Git Workflow</h4>
<div style="margin: 20px 0;">
<span class="workflow-step">Working Directory</span>
<span class="workflow-step">Staging Area</span>
<span class="workflow-step">Repository</span>
</div>
</div>
</div>
<!-- GitHub Integration Card -->
<div class="tutorial-card">
<div class="card-header">
<div class="card-icon">π</div>
<h2 class="card-title">GitHub Integration</h2>
</div>
<div class="step">
<span class="step-number">1</span>
<strong>Create GitHub Repository</strong>
<p>Go to <a href="https://github.com" target="_blank">GitHub.com</a> β New Repository</p>
</div>
<div class="step">
<span class="step-number">2</span>
<strong>Add Remote Origin</strong>
<div class="command-block">
git remote add origin https://github.com/username/repo-name.git
<button class="copy-btn" onclick="copyToClipboard(this)">Copy</button>
</div>
</div>
<div class="step">
<span class="step-number">3</span>
<strong>Push to GitHub</strong>
<div class="command-block">
git push -u origin main
<button class="copy-btn" onclick="copyToClipboard(this)">Copy</button>
</div>
</div>
<div class="warning">
β οΈ Make sure to replace "username" and "repo-name" with your actual GitHub username and repository name!
</div>
</div>
<!-- Branching Card -->
<div class="tutorial-card">
<div class="card-header">
<div class="card-icon">πΏ</div>
<h2 class="card-title">Branching & Merging</h2>
</div>
<div class="step">
<span class="step-number">1</span>
<strong>Create Branch</strong>
<div class="command-block">
git branch feature-branch
<button class="copy-btn" onclick="copyToClipboard(this)">Copy</button>
</div>
</div>
<div class="step">
<span class="step-number">2</span>
<strong>Switch to Branch</strong>
<div class="command-block">
git checkout feature-branch
<button class="copy-btn" onclick="copyToClipboard(this)">Copy</button>
</div>
<p><em>Or create and switch in one command:</em></p>
<div class="command-block">
git checkout -b feature-branch
<button class="copy-btn" onclick="copyToClipboard(this)">Copy</button>
</div>
</div>
<div class="step">
<span class="step-number">3</span>
<strong>Merge Branch</strong>
<div class="command-block">
git checkout main
<button class="copy-btn" onclick="copyToClipboard(this)">Copy</button>
</div>
<div class="command-block">
git merge feature-branch
<button class="copy-btn" onclick="copyToClipboard(this)">Copy</button>
</div>
</div>
</div>
<!-- Advanced Commands Card -->
<div class="tutorial-card">
<div class="card-header">
<div class="card-icon">π₯</div>
<h2 class="card-title">Advanced Git</h2>
</div>
<div class="step">
<span class="step-number">1</span>
<strong>View History</strong>
<div class="command-block">
git log --oneline
<button class="copy-btn" onclick="copyToClipboard(this)">Copy</button>
</div>
</div>
<div class="step">
<span class="step-number">2</span>
<strong>Undo Changes</strong>
<div class="command-block">
git reset --hard HEAD~1
<button class="copy-btn" onclick="copyToClipboard(this)">Copy</button>
</div>
<div class="command-block">
git revert HEAD
<button class="copy-btn" onclick="copyToClipboard(this)">Copy</button>
</div>
</div>
<div class="step">
<span class="step-number">3</span>
<strong>Stash Changes</strong>
<div class="command-block">
git stash
<button class="copy-btn" onclick="copyToClipboard(this)">Copy</button>
</div>
<div class="command-block">
git stash pop
<button class="copy-btn" onclick="copyToClipboard(this)">Copy</button>
</div>
</div>
<div class="warning">
β οΈ Be careful with reset --hard as it permanently deletes changes!
</div>
</div>
</div>
<!-- Interactive Quiz Section -->
<div class="quiz-section">
<h2>π§ Test Your Knowledge!</h2>
<p id="quizQuestion">Which command initializes a new Git repository?</p>
<div>
<button class="quiz-button" onclick="checkAnswer(this, false)">git start</button>
<button class="quiz-button" onclick="checkAnswer(this, true)">git init</button>
<button class="quiz-button" onclick="checkAnswer(this, false)">git create</button>
<button class="quiz-button" onclick="checkAnswer(this, false)">git new</button>
</div>
<p id="quizResult" style="margin-top: 15px; font-weight: bold;"></p>
</div>
<!-- Practical Exercise -->
<div class="tutorial-card" style="grid-column: 1 / -1;">
<div class="card-header">
<div class="card-icon">π»</div>
<h2 class="card-title">Hands-On Exercise</h2>
</div>
<h3>Create Your First Project</h3>
<ol style="padding-left: 20px;">
<li>Create a new folder called "my-first-repo"</li>
<li>Initialize it as a Git repository</li>
<li>Create a README.md file with your project description</li>
<li>Add and commit the file</li>
<li>Create a GitHub repository</li>
<li>Push your local repository to GitHub</li>
</ol>
<div class="success">
π Congratulations! You've completed your first Git & GitHub workflow!
</div>
</div>
</div>
<script>
let progress = 0;
const totalCards = 6;
// Copy to clipboard function
function copyToClipboard(button) {
const commandBlock = button.parentElement;
const command = commandBlock.textContent.replace('Copy', '').replace('$ ', '').trim();
navigator.clipboard.writeText(command).then(function() {
button.textContent = 'Copied!';
button.style.background = '#48bb78';
setTimeout(function() {
button.textContent = 'Copy';
button.style.background = '#667eea';
}, 2000);
}).catch(function(err) {
console.error('Could not copy text: ', err);
button.textContent = 'Error';
});
}
// Quiz functionality
function checkAnswer(button, isCorrect) {
const resultElement = document.getElementById('quizResult');
const allButtons = document.querySelectorAll('.quiz-button');
// Disable all buttons
allButtons.forEach(btn => btn.disabled = true);
if (isCorrect) {
button.style.background = '#48bb78';
resultElement.textContent = 'β
Correct! git init initializes a new repository.';
resultElement.style.color = '#48bb78';
updateProgress();
} else {
button.style.background = '#f56565';
resultElement.textContent = 'β Incorrect. The correct answer is "git init".';
resultElement.style.color = '#f56565';
}
// Reset after 3 seconds
setTimeout(function() {
allButtons.forEach(btn => {
btn.disabled = false;
btn.style.background = 'white';
});
resultElement.textContent = '';
}, 3000);
}
// Update progress bar
function updateProgress() {
progress += (100 / totalCards);
const progressBar = document.getElementById('progressBar');
progressBar.style.width = Math.min(progress, 100) + '%';
}
// Card hover animation
document.querySelectorAll('.tutorial-card').forEach(card => {
card.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-5px) scale(1.02)';
});
card.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0) scale(1)';
});
});
// Smooth scroll for any internal links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Animate cards on scroll (simplified version)
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -100px 0px'
};
const observer = new IntersectionObserver(function(entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
// Initially hide cards for animation
document.querySelectorAll('.tutorial-card').forEach(card => {
card.style.opacity = '0';
card.style.transform = 'translateY(30px)';
card.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(card);
});
// Welcome message
console.log('π Welcome to the Git & GitHub Tutorial!');
console.log('π‘ Tip: Use the copy buttons to quickly copy commands to your terminal.');
</script>
</body>
</html>