Git 101: version control คือระบบ save ที่มีความจำGit 101: version control is a save system with memory
เข้าใจว่า Git คืออะไร repository คืออะไร และทำไม status, snapshot และ history ถึงสำคัญก่อนเริ่มท่อง commandUnderstand what Git is, what a repository is, and why status, snapshots, and history matter before memorizing commands.
Git is a version-control tool.
That sounds technical, but the useful idea is simple:
Git helps you save meaningful versions of a project, compare changes, and go back through history.
It is not the same thing as GitHub. Git is the tool. GitHub is one popular website where Git repositories can be shared.
Why Git matters
Without Git, project history often looks like this:
report-final.docx
report-final-v2.docx
report-final-v2-real-final.docx
report-final-v2-real-final-pichaya-edit.docx
Git gives you a cleaner system:
- one project folder
- saved checkpoints called commits
- messages explaining why each checkpoint exists
- a way to compare what changed
- branches for safe experiments
This matters for AI work because AI agents can edit many files quickly. Git gives you a way to inspect those edits before trusting them.
The core objects
Learn these words first.
| Word | Meaning |
|---|---|
| repository | a project folder tracked by Git |
| working tree | the files you are editing right now |
| staging area | the set of changes selected for the next commit |
| commit | a saved snapshot with a message |
| branch | a movable line of work |
| remote | another copy of the repository, often on GitHub |
You do not need to master every command today. You need a map.
Git is local first
Git works on your computer even without the internet.
You can:
- create a repository
- edit files
- check status
- commit changes
- create branches
- inspect history
Only sharing with another server needs a remote such as GitHub.
The beginner loop
The Git loop you will repeat most often is:
edit files
git status
git diff
git add
git commit
Read that as:
- Change something.
- Ask Git what changed.
- Inspect the exact difference.
- Choose what belongs in the next save point.
- Save it with a message.
The safest habit is to run git status more often than you think you need.
What Git does not do
Git does not automatically understand whether your work is good.
It will happily save:
- broken code
- unclear documents
- secrets you should not commit
- generated files you did not mean to track
Git gives you memory. You still need judgment.
Practice: explain the map
Before running commands, fill this out:
Git is:
GitHub is:
A repository is:
A commit is:
A branch is:
The command I should run often is:
If you can explain those in plain language, the commands will make more sense.
Git คือเครื่องมือ version control
ฟังดู technical แต่ไอเดียที่ใช้ได้จริงง่ายมาก:
Git ช่วยให้คุณ save version สำคัญของ project, เปรียบเทียบการเปลี่ยนแปลง และย้อนดูประวัติได้
Git ไม่เหมือน GitHub นะครับ Git คือเครื่องมือ ส่วน GitHub คือเว็บไซต์ยอดนิยมที่ใช้ share Git repository
ทำไม Git สำคัญ
ถ้าไม่มี Git ประวัติ project มักหน้าตาแบบนี้:
report-final.docx
report-final-v2.docx
report-final-v2-real-final.docx
report-final-v2-real-final-pichaya-edit.docx
Git ให้ระบบที่สะอาดกว่า:
- project folder เดียว
- จุด save ที่เรียกว่า commit
- message อธิบายว่าทำไมมีจุด save นี้
- วิธีเปรียบเทียบว่าอะไรเปลี่ยน
- branch สำหรับทดลองอย่างปลอดภัย
สิ่งนี้สำคัญกับงาน AI เพราะ AI agent แก้หลายไฟล์ได้เร็วมาก Git ช่วยให้คุณตรวจ edit เหล่านั้นก่อนเชื่อ
ของหลักที่ต้องรู้
จำคำเหล่านี้ก่อน:
| คำ | ความหมาย |
|---|---|
| repository | project folder ที่ Git ติดตาม |
| working tree | ไฟล์ที่คุณกำลังแก้อยู่ตอนนี้ |
| staging area | ชุด change ที่เลือกไว้สำหรับ commit ถัดไป |
| commit | snapshot ที่ save พร้อม message |
| branch | เส้นทางทำงานที่ขยับได้ |
| remote | repository อีกชุดหนึ่ง มักอยู่บน GitHub |
วันนี้ยังไม่ต้องเชี่ยว command ทุกตัว ต้องมีแผนที่ก่อน
Git เริ่มจาก local
Git ทำงานบนเครื่องคุณได้แม้ไม่มี internet
คุณสามารถ:
- สร้าง repository
- แก้ไฟล์
- เช็ก status
- commit change
- สร้าง branch
- อ่าน history
มีแค่ตอน share กับ server อื่นที่ต้องใช้ remote เช่น GitHub
Loop สำหรับมือใหม่
loop ของ Git ที่จะใช้บ่อยที่สุดคือ:
edit files
git status
git diff
git add
git commit
อ่านได้แบบนี้:
- แก้อะไรบางอย่าง
- ถาม Git ว่าอะไรเปลี่ยน
- ตรวจความต่างแบบละเอียด
- เลือก change ที่จะเข้า save point ถัดไป
- save พร้อม message
นิสัยที่ปลอดภัยที่สุดคือรัน git status บ่อยกว่าที่คิดว่าจำเป็น
Git ไม่ได้ทำอะไรให้
Git ไม่ได้เข้าใจเองว่างานของคุณดีหรือไม่
มัน save ได้หมด:
- code ที่พัง
- เอกสารที่ไม่ชัด
- secret ที่ไม่ควร commit
- ไฟล์ generate ที่คุณไม่ได้ตั้งใจ track
Git ให้ความจำ แต่คุณยังต้องใช้ judgment
แบบฝึก: อธิบายแผนที่
ก่อนเริ่ม command ให้เติม:
Git คือ:
GitHub คือ:
Repository คือ:
Commit คือ:
Branch คือ:
Command ที่ควรรันบ่อยคือ:
ถ้าอธิบายสิ่งเหล่านี้เป็นภาษาคนได้ command จะเข้าใจง่ายขึ้นมาก
บทถัดไป: Git 102 - สร้าง repo และอ่าน status
เข้าสู่ระบบเพื่อบันทึกความคืบหน้าSign in to track your progress
เข้าสู่ระบบSign in→