-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub-masterclass-tutorial.html
More file actions
266 lines (224 loc) · 13.5 KB
/
github-masterclass-tutorial.html
File metadata and controls
266 lines (224 loc) · 13.5 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Git & GitHub Masterclass 🐙</title>
<!-- Google Fonts -->
<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=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<!-- Highlight.js for Code Formatting -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
<script>hljs.highlightAll();</script>
<style>
:root {
--bg-color: #0f0a1c;
--surface-color: #1a1625;
--primary-color: #f97316; /* Orange for Git */
--primary-glow: rgba(249, 115, 22, 0.4);
--text-main: #f8fafc;
--text-muted: #94a3b8;
--border-color: rgba(255, 255, 255, 0.08);
--card-border: rgba(255, 255, 255, 0.1);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
font-family: 'Plus Jakarta Sans', sans-serif;
background-color: var(--bg-color); color: var(--text-main); line-height: 1.6;
background-image:
radial-gradient(at 0% 0%, rgba(249, 115, 22, 0.1) 0px, transparent 50%),
radial-gradient(at 100% 100%, rgba(234, 88, 12, 0.1) 0px, transparent 50%);
background-attachment: fixed; min-height: 100vh;
}
.layout { display: flex; gap: 2.5rem; max-width: 1400px; margin: 0 auto; padding: 3rem 2rem; }
/* Sidebar Styles (Reused) */
.sidebar {
width: 280px; flex-shrink: 0; position: sticky; top: 3rem; max-height: calc(100vh - 6rem); overflow-y: auto;
background: rgba(26, 22, 37, 0.8); border: 1px solid var(--card-border); border-radius: 16px; padding: 1.5rem;
backdrop-filter: blur(12px);
}
.sidebar h3 {
margin-bottom: 1rem; font-size: 1.1rem; text-transform: uppercase; letter-spacing: 1.5px;
color: var(--primary-color); border-bottom: 1px solid var(--card-border); padding-bottom: 1rem;
}
.sidebar ul { list-style: none; }
.sidebar li { margin-bottom: 0.3rem; }
.nav-section {
font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted);
margin: 1.5rem 0 0.5rem 0; padding-left: 0.5rem; font-weight: 700;
}
.sidebar a {
text-decoration: none; color: var(--text-muted); display: block; padding: 0.5rem 1rem;
border-radius: 8px; transition: all 0.3s ease; font-size: 0.95rem; font-weight: 500;
}
.sidebar a.active {
background: rgba(249, 115, 22, 0.2); color: #fff; border-left: 3px solid var(--primary-color); border-radius: 4px 8px 8px 4px;
}
.sidebar a:hover:not(.active) { background: rgba(249, 115, 22, 0.15); color: var(--primary-color); transform: translateX(5px); }
.main-content { flex: 1; min-width: 0; }
header { text-align: center; margin-bottom: 3rem; }
h1 {
font-size: 3rem; font-weight: 800; margin-bottom: 1rem;
background: linear-gradient(135deg, var(--primary-color) 0%, #fb923c 100%);
-webkit-background-clip: text; -webkit-text-fill-color: transparent; text-shadow: 0 0 40px var(--primary-glow);
}
.subtitle { font-size: 1.2rem; color: var(--text-muted); }
/* Content Blocks */
.content-card {
background: rgba(26, 22, 37, 0.6); border: 1px solid var(--card-border);
border-radius: 16px; padding: 2.5rem; margin-bottom: 2rem; backdrop-filter: blur(10px);
box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.5);
}
h2 { font-size: 1.8rem; margin-bottom: 1.5rem; display: flex; align-items: center; gap: 0.5rem; color: #fff; border-bottom: 1px solid var(--border-color); padding-bottom: 1rem; }
h3 { font-size: 1.3rem; margin: 1.5rem 0 1rem; color: #e2e8f0; }
p { margin-bottom: 1rem; font-size: 1.1rem; color: #c9d1d9; }
ul { margin-left: 1.5rem; margin-bottom: 1rem; color: #c9d1d9; }
li { margin-bottom: 0.5rem; }
.explanation { background: rgba(249, 115, 22, 0.1); border-left: 4px solid var(--primary-color); padding: 1rem 1.5rem; border-radius: 0 8px 8px 0; margin: 1.5rem 0; }
.explanation p { margin-bottom: 0; color: #e2e8f0; }
pre { background: #010409 !important; border: 1px solid var(--border-color); border-radius: 12px; padding: 1.5rem !important; margin: 1.5rem 0; overflow-x: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
code { font-family: 'JetBrains Mono', monospace !important; font-size: 0.95rem; line-height: 1.5; }
.diagram { font-family: 'JetBrains Mono', monospace; background: #050505; color: #fb923c; padding: 1.5rem; border-radius: 12px; border: 1px solid var(--primary-color); box-shadow: 0 0 20px rgba(249, 115, 22, 0.1); overflow-x: auto; white-space: pre; line-height: 1.4; margin: 1.5rem 0; font-size: 0.9rem; }
.terminal-block { background: #000; border: 1px solid #333; border-radius: 8px; font-family: 'JetBrains Mono'; padding: 1rem; color: #10b981; margin-bottom: 1.5rem;}
.terminal-block .prompt { color: #f97316; }
@media (max-width: 900px) {
.layout { flex-direction: column; }
.sidebar { width: 100%; position: relative; top: 0; max-height: none; margin-bottom: 2rem; }
}
</style>
</head>
<body>
<div class="layout">
<!-- Sidebar Navigation -->
<aside class="sidebar">
<h3>🗂️ Tutorials Link</h3>
<nav>
<ul>
<li><a href="index.html">🏠 Home Hub</a></li>
<li class="nav-section">Databases / Lang</li>
<li><a href="mongodb-conditions-tutorial.html">🍃 MongoDB Class</a></li>
<li><a href="redis-masterclass-tutorial.html">🔥 Redis</a></li>
<li><a href="typescript-oops-tutorial.html">📘 TS OOPs</a></li>
<li class="nav-section">Architecture</li>
<li><a href="message-queues-tutorial.html">📨 Message Queues</a></li>
<li><a href="notification-system-tutorial.html">🔔 Notifications</a></li>
<li><a href="worker-threads-tutorial.html">⚙️ Node Workers</a></li>
<li><a href="system-design-tutorial.html">🏗️ Sys Design (Part 1)</a></li>
<li><a href="system-design-part2.html">🚀 Sys Design (Part 2)</a></li>
<li class="nav-section">Security & DevOps</li>
<li><a href="github-masterclass-tutorial.html" class="active">🐙 Git & GitHub</a></li>
<li><a href="rbac-masterclass-tutorial.html">🔐 RBAC & Auth</a></li>
<li><a href="abac-masterclass-tutorial.html">🛡️ ABAC Policies</a></li>
</ul>
</nav>
</aside>
<!-- Main Content -->
<main class="main-content">
<header>
<h1>Git & GitHub Masterclass 🐙</h1>
<p class="subtitle">Command Line Ninja Guide, SSH Keys, Repositories, and Automation Pipelines!</p>
</header>
<div class="content-card" id="intro">
<h2>1. Git vs GitHub (The Difference)</h2>
<p>Naye developers ko lagta hai "Git" and "GitHub" ek hi cheez hai. Aisa nahi hai:</p>
<ul>
<li><strong>Git:</strong> Ek software hai tere laptop pe jo code ki history track karta hai. (Jaise tere mobile ka camera software).</li>
<li><strong>GitHub:</strong> Microsoft ki cloud website hai jahan tu us track kiye hue code ka backup safely store karke rakhta hai. (Jaise Google Photos / iCloud).</li>
</ul>
<div class="explanation">
<p>👉 Agar kal tera laptop chori ho jaye, toh GitHub se tune jitna bhi cloud me save kiya tha wapas la sakta hai kisi bhi brand new system par.</p>
</div>
</div>
<div class="content-card" id="commands">
<h2>2. The Holy Trinity of Commands</h2>
<p>Jab bhi tu project me koi change karta hai (jaise nayi file banana or purane bugs resolve karna), tujhe ye 3 commands har bar dalni hoti hain to push to the cloud:</p>
<div class="terminal-block">
<span class="prompt">$</span> git add .<br>
<span style="color: #64748b;">// Iska matlab: Saari changed files ko "Staging area" me taiyar karo.</span><br><br>
<span class="prompt">$</span> git commit -m "Added login form UI"<br>
<span style="color: #64748b;">// Iska matlab: Ek seal lagao message ke sath ki maine isme "Kya" badla hai. Local laptop me save ho gaya!</span><br><br>
<span class="prompt">$</span> git push origin main<br>
<span style="color: #64748b;">// Iska matlab: Local se code uthao aur "origin" (GitHub website) ki "main" branch par daal do duniya ke dekhne ke liye.</span>
</div>
</div>
<div class="content-card" id="ssh">
<h2>3. SSH Keys (The Hacker Way to Login)</h2>
<p>Terminal mein `git push` maarte waqt agar GitHub baar-baar username or password maang raha hai, toh it's extremely annoying.</p>
<p>Is problem ko permanently bypass karne ka tareeqa hai <strong>SSH Keys</strong> (Secure Shell). Ye do taale (locks) jaisa system hai: Ek Public Key aur Ek Private Key.</p>
<pre><code class="language-bash"># Step 1: Open VS Code Terminal or Bash and Generate Key
ssh-keygen -t ed25519 -C "tera_email@gmail.com"
# Press ENTER continuously (don't set a passphrase if you want it to be fully automatic)
# Step 2: Read the public key generated
cat ~/.ssh/id_ed25519.pub
# Step 3: Copy that weird text output. Go to github.com -> Profile -> Settings -> SSH Keys -> Add New
# Paste it there!
# Step 4: Test Connection magically
ssh -T git@github.com
# Should say "Hi username! You've successfully authenticated!"
</code></pre>
</div>
<div class="content-card" id="branching">
<h2>4. Branching Model (Working with Teams)</h2>
<p>Direct `main` branch me commit push dalna Production Code tod sakta hai. Real world me hamesha alag-alag branches banti hain.</p>
<div class="diagram">
(main) o --- o --- o -------- o --- o (Live Code)
\ /
(feature) o --- o --- o (Tera isolated feature)
</div>
<h3>Useful Commands:</h3>
<ul>
<li><code>git branch user-auth</code> -> Nayi branch banana.</li>
<li><code>git checkout user-auth</code> -> Us new branch ke andar khudko shift karna.</li>
<li><code>git checkout -b payments</code> -> Shortcut dono upper wale kaam ek hi line me karna.</li>
</ul>
</div>
<div class="content-card" id="cicd">
<h2>5. GitHub Actions (The Automation Magic CI/CD)</h2>
<p>Standard developers live server (AWS / DigitalOcean / cPanel) pe code khud manually upload / unzip nahi karte. Ye kaam GitHub ke remote servers (called <b>Actions</b> or <b>Runners</b>) automatically karte hain!</p>
<div class="explanation">
<p>👉 <strong>Definition: CI/CD Pipeline</strong>. Jese hi tu <code>git push origin main</code> marega, GitHub ek free Linux computer start karta hai background mein, tere Tests (npm run test) chlaata hai. Agar test Paas hota hai, tou SSH ke zariye seedha AWS EC2 instance par connect karke waha ka code automatically restart/update kardeta hai.</p>
</div>
<pre><code class="language-yaml"># File: .github/workflows/deploy.yml (Create inside your Repo)
name: Node.js CI Auto Deploy
on:
push:
branches: [ "main" ] # Sirf "main" branch pe trigger hoga ye script
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install and Test
run: |
npm install
npm run test
- name: Deploy to EC2 Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_AWS_IP }}
username: ubuntu
key: ${{ secrets.AWS_PEM_KEY }}
script: |
cd ~/my-backend-project
git pull origin main
npm install
pm2 restart all
</code></pre>
</div>
<div class="cta-banner" style="margin-top: 2rem; background: rgba(249, 115, 22, 0.1); border: 1px solid var(--primary-color); padding: 2rem; border-radius: 16px; text-align: center;">
<h2>Tu Ab Git Expert Hai! 🚀</h2>
<p>SSH set ho gaya, basic pull/push flows aa gae aur CD pipeline ki deep theory dimaag me chhap gai hai!<br><br>
<strong>Keep pushing code! 🔥</strong>
</p>
</div>
</main>
</div>
</body>
</html>