Toolstools / github

GitHub

Apa ini

GitHub simpan code online.

Ia bantu simpan versions, collaborate, review changes, dan connect project ke deployment tools seperti Vercel.

Kenapa penting

Tanpa GitHub, project terperangkap dekat satu computer.

Dengan GitHub, kerja boleh backup, review, share dengan tutor, dan deploy.

Apa nak buat

Core idea

Flow

local folder -> git commit -> GitHub repository -> Vercel deploy

Git menjejak project dalam komputer pelajar. GitHub simpan salinan online.

Create account

  1. Pergi ke github.com.
  2. Create account atau sign in.
  3. Verify email.
  4. Guna username yang professional enough untuk share.
  5. Turn on two-factor authentication bila GitHub minta.

Create repository

  1. Click New repository dalam GitHub.
  2. Guna nama simple lowercase macam cafe-website.
  3. Pilih Public untuk class demo atau Private untuk personal work.
  4. Jangan add README kalau nak push existing local project.
  5. Click Create repository.

Visual checkpoint:

Reference

Repository page
  Owner/name: betul
  Visibility: public atau private
  Code tab: empty atau files nampak
  Green Code button: visible

Push existing project

Run dalam project folder:

Terminal command
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/USERNAME/REPO-NAME.git
git push -u origin main

Kalau Git cakap remote already exists:

Terminal command
git remote -v

Kalau URL salah:

Terminal command
git remote set-url origin https://github.com/USERNAME/REPO-NAME.git

Core features

FeatureMaksudBeginner action
RepositoryOnline project folderSatu project = satu repo.
CommitSaved checkpointCommit selepas working change.
BranchSeparate version pathStay dekat main untuk Vibe 101.
RemoteConnection ke GitHubBiasanya nama origin.
Pull requestReview workflowBelajar later, tak perlu untuk first deploy.
READMEExplanation projectAdd simple summary selepas first push.
.gitignoreFiles yang Git skipJangan push node_modules atau .env.local.

Secret safety

Jangan commit:

  • .env
  • .env.local
  • API keys
  • database passwords
  • private tokens

Check sebelum push:

Terminal command
git status

Kalau .env.local muncul, stop dan fix .gitignore.

Mistake biasa

  • Upload dependency folders.
  • Guna repository name yang unclear.
  • Lupa commit sebelum push.
  • Create GitHub repo dengan README, then kena merge conflict.
  • Push secrets.
  • Deploy sebelum code terkini dipush.

Next step

Pergi ke Vercel.