🐙 วิธีใช้ GitHub — Beginner Guide ภาษาไทย
🏠 หน้าแรก
🎉 ข่าวดี! GitHub Memberships ฟรี สามารถสร้าง Private Repo ได้ไม่จำกัด
ตั้งแต่ปี 2019 GitHub เปลี่ยนนโยบาย — ผู้ใช้ฟรี (Free Plan) สร้าง Private Repository
ได้ไม่จำกัดจำนวน ไม่มีข้อจำกัดเรื่อง collaborators ไม่ต้องเสียตัง!
📌 GitHub คืออะไร?
GitHub เป็นบริการเก็บ Git Repository บน cloud — ใช้สำหรับ:
- Backup code — ไม่กลัวข้อมูลหาย ถึงเครื่องพังก็กู้คืนได้
- Version control — ดูประวัติการแก้ไข กลับไปเวอร์ชั่นเก่าได้
- Collaborate — ทำงานร่วมกับทีม หรือเปิดให้คนอื่นดู code
- Portfolio — โชว์ผลงานให้ HR หรือเพื่อน developer ดู
🔑 ตั้งค่า GitHub + SSH Key (ครั้งแรก)
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"
4
แสดง SSH public key แล้วเอาไปใส่ใน GitHub
cat ~/.ssh/id_ed25519.pub
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
เท่านี้ code ทั้งหมดก็ถูก backup ไปที่ GitHub แล้ว! 🎉
📥 ดึง Code จาก GitHub (Clone)
เมื่อต้องการดึง code จาก GitHub มาที่เครื่องใหม่:
git clone git@github.com:your-username/my-project.git
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)
git status
git add -A
git commit -m "✨ description สั้น ๆ"
git push
⚠️ Tips:
- Commit บ่อย ๆ — commit เล็ก ๆ ดีกว่า commit ใหญ่ ๆ
- เขียนข้อความ commit ให้สื่อความหมาย (เช่น "แก้ bug login", "เพิ่มหน้า fortune")
- Push ทุกครั้งที่เลิกทำงาน — ป้องกันข้อมูลหาย
🔒 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 เช่น:
.env
.idea/
.vscode/
.DS_Store
Thumbs.db
vendor/
node_modules/
*/tts_cache/
__pycache__/
*.pyc
🤖 ข้อมูลบนเว็บไซต์นี้
🧠 ค้นคว้าและเรียบเรียงโดย
Hermes AI Agent — หาข้อมูลเองจ้ะ 🤖✨
ตัวอย่างผลงานที่ Hermes ค้นคว้า:
- 🛡️ WSS Vendor Solutions — เปรียบเทียบ Tenable, Splunk, Radware, Cisco vs WSS 1.0
- 🔬 Tenable — Nessus, Tenable.io, Cloud Security
- 📊 Splunk — SIEM, SOAR, UBA, Enterprise Security
- 🛡️ Radware — WAF, DDoS Protection, Bot Manager
- 🌐 Cisco — Firepower, Secure Endpoint, Duo, ISE, Umbrella, XDR
- 🔐 Zero Trust Architecture — NIST SP 800-207
- 👁️ Visibility & Segmentation — การมองเห็นและแบ่งส่วนเครือข่าย
🐙 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 โดยไม่ลบไฟล์จริง