🐙 วิธีใช้ GitHub — Beginner Guide ภาษาไทย

🏠 หน้าแรก
🎉 ข่าวดี! GitHub Memberships ฟรี สามารถสร้าง Private Repo ได้ไม่จำกัด
ตั้งแต่ปี 2019 GitHub เปลี่ยนนโยบาย — ผู้ใช้ฟรี (Free Plan) สร้าง Private Repository ได้ไม่จำกัดจำนวน ไม่มีข้อจำกัดเรื่อง collaborators ไม่ต้องเสียตัง!

📌 GitHub คืออะไร?

GitHub เป็นบริการเก็บ Git Repository บน cloud — ใช้สำหรับ:

🔑 ตั้งค่า GitHub + SSH Key (ครั้งแรก)

1
สมัคร GitHub — ไปที่ github.com/signup กรอกอีเมล + รหัสผ่าน
2
ตั้งชื่อ user + email ใน Git
git config --global user.name "Your Name"
git config --global user.email "your-email@example.com"
3
สร้าง SSH Key (ใช้เชื่อมต่อแบบไม่ต้องกรอกรหัสผ่าน)
ssh-keygen -t ed25519 -C "your-email@example.com"
# กด Enter ไปเรื่อย ๆ (ไม่ต้องตั้ง passphrase ก็ได้)
4
แสดง SSH public key แล้วเอาไปใส่ใน GitHub
cat ~/.ssh/id_ed25519.pub
# คัดลอกข้อความที่ได้ (ขึ้นต้นด้วย ssh-ed25519 ...)
# ไปที่ GitHub → Settings → SSH and GPG keys → New SSH key
# วาง key แล้วกด Add
5
ทดสอบการเชื่อมต่อ
ssh -T git@github.com
# Hi your-username! You've successfully authenticated...

🚀 Push โปรเจกต์ของเราไป GitHub

1
สร้าง Repo บน GitHub
  • ไปที่ github.com/new
  • ใส่ชื่อ repo (เช่น my-project)
  • เลือก Private (ถ้าต้องการให้คนอื่นไม่เห็น)
  • ไม่ต้อง勾选 Anything — กด Create repository
2
เชื่อม local repo กับ GitHub
cd ~/project
git remote add origin git@github.com:your-username/my-project.git
git push -u origin master
# 🔁 ครั้งแรกจะใช้เวลานิดหน่อย 160 files (21,952 insertions)

เท่านี้ code ทั้งหมดก็ถูก backup ไปที่ GitHub แล้ว! 🎉

📥 ดึง Code จาก GitHub (Clone)

เมื่อต้องการดึง code จาก GitHub มาที่เครื่องใหม่:

git clone git@github.com:your-username/my-project.git
# หรือใช้ HTTPS (กรณีไม่มี SSH key):
git clone https://github.com/your-username/my-project.git

🔄 การใช้งาน Git เบื้องต้น

 🔍 เช็คสถานะ
git status — ดูว่ามีไฟล์ไหน改了บ้าง
 ➕ เพิ่มไฟล์
git add -A — เพิ่มทุกไฟล์
git add index.html — เพิ่มแค่ไฟล์เดียว
 💾 Commit
git commit -m "ข้อความ" — บันทึก snapshot
 📤 Push
git push — อัปโหลดไป GitHub
 📥 Pull
git pull — ดึง version ล่าสุดจาก GitHub
 📜 ดูประวัติ
git log --oneline — ดู commits ทั้งหมด
git diff — ดูอะไร改了บ้าง

🔄 Workflow ปกติ (ทุกครั้งที่แก้ไข code)

# 1. เช็คสถานะ
git status

# 2. เพิ่มไฟล์ที่แก้ไข
git add -A

# 3. บันทึก (commit)
git commit -m "✨ description สั้น ๆ"

# 4. อัปโหลดไป GitHub
git push
⚠️ Tips:

🔒 Private Repo: Public vs Private

🌍 Public
ทุกคนเห็น code ได้ — เหมาะกับ open source, portfolio
🔒 Private
เฉพาะเรา + คนที่เราเพิ่ม — ฟรี! ไม่จำกัดจำนวน!
✅ GitHub Free Plan: ได้ Private Repo ไม่จำกัด, Collaborators ไม่จำกัด, Actions 2,000 นาที/เดือนฟรี

📁 .gitignore — ไม่ต้อง commit ไฟล์ที่ไม่จำเป็น

ไฟล์ .gitignore บอก Git ว่าไฟล์ไหนไม่ควร commit เช่น:

# Environment
.env

# IDE
.idea/
.vscode/

# System
.DS_Store
Thumbs.db

# Dependencies (สามารถเพิ่มได้ ถ้าใช้ composer/npm)
vendor/
node_modules/

# Cache / Temp
*/tts_cache/
__pycache__/
*.pyc

🤖 ข้อมูลบนเว็บไซต์นี้

🧠 ค้นคว้าและเรียบเรียงโดย
Hermes AI Agent — หาข้อมูลเองจ้ะ 🤖✨

ตัวอย่างผลงานที่ Hermes ค้นคว้า:

🐙 GitHub Features ที่น่าสนใจ

🚀 GitHub Actions
CI/CD auto-test, auto-deploy — ฟรี 2,000 นาที/เดือน
📖 GitHub Pages
โฮสต์เว็บ static ฟรี — username.github.io
🐛 Issues
ระบบติดตาม bug + feature request
📋 Projects
Kanban board ในตัว (คล้าย Trello)
🔀 Pull Requests
ขอ merge code — code review ก่อนรวม
🛡️ Security
แจ้งเตือน vulnerability + Dependabot auto-fix

❓ FAQ — คำถามที่พบบ่อย

❓ Private repo เสียตังไหม?
ไม่เสีย! GitHub Free Plan มี Private Repo ได้ไม่จำกัดตั้งแต่ 2019
❓ GitHub กับ Git ต่างกันยังไง?
Git = ระบบ version control (software ที่ติดตั้งในเครื่อง), GitHub = บริการ cloud ที่เก็บ Git repo (website)
❓ push ไม่ได้ขึ้น error: failed to push
ลอง git pull ก่อน แล้วค่อย git push อีกครั้ง หรือถ้า SSH key ไม่ได้ตั้ง ใช้ git remote set-url origin https://...
❓ อยากยกเลิก commit ล่าสุด?
git reset --soft HEAD~1 — ยกเลิก commit แต่เก็บไฟล์ไว้
git reset --hard HEAD~1 — ยกเลิก commit + เอาไฟล์ออก (ระวัง!)
❓ ลืมใส่ .gitignore จะลบไฟล์ออกจาก Git ยังไง?
git rm --cached <file> — ลบ tracking โดยไม่ลบไฟล์จริง