พื้นฐาน Git พร้อมผู้ช่วยปัญญาประดิษฐ์
คอมมิต สร้างสาขา และพุช โดยมีคำแนะนำจากปัญญาประดิษฐ์
พื้นฐาน Git พร้อมผู้ช่วยปัญญาประดิษฐ์ เป็นบทเรียน Vibe Coding ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Vibe Coding และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Vibe Coding มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
From Theory to Hands-On
Last lesson you learned why version control matters. Now you'll actually use it — and you won't memorize a single command.
Your AI assistant (Cursor, Claude Code, Copilot, or even ChatGPT) will write every Git command for you. Your job is to understand what each step does so you stay in control.
By the end, you'll have made a commit, a branch, and a push. Let's go.
The Four Core Actions
99% of Git work is just four actions:
- init — start tracking a project (once per project)
- commit — save a snapshot
- branch — make a parallel copy to experiment
- push — upload your snapshots to GitHub
Learn these four and you can build real apps. Everything else you can ask AI for as you need it.
Starting a Project (init)
To begin tracking a folder, you run git init once. Most tools (Cursor, Replit, GitHub Desktop) do this with a button, but here's what it looks like.
Don't type this blindly — paste it into your AI and ask it to confirm. Here's a prompt to do that:
I'm in my project folder in the VS Code terminal.
Walk me through starting Git tracking for this project, step by step.
I think the first command is `git init` -- confirm that, tell me
exactly what to type, and what I should see after each command.Staging vs Committing
One thing that confuses beginners: before you commit, you stage your changes. Staging means "these are the changes I want in this snapshot."
Two-step rhythm: stage what you want, then commit it with a message.
git add .— stage all your changesgit commit -m "Add homepage"— save the snapshot
Think of staging as putting items in a box, and committing as sealing and labeling the box.
Your First Commit Prompt
Here's the exact prompt to make your first commit. Paste it into your AI assistant and follow along:
I just built my homepage and it works. I want to save this snapshot.
Give me the exact terminal commands to:
1. Stage all my changes
2. Commit them with the message "Add working homepage"
Then explain what each command did in one sentence.Seeing Your History
After a few commits, you'll want to see your history. The command is git log. Tools show it as a clickable timeline.
Here's a tiny simulation of what your history feels like — a list of save points with messages:
const log = [
{ hash: 'a1b2c3', msg: 'Add working homepage' },
{ hash: 'd4e5f6', msg: 'Add navigation bar' },
{ hash: '7g8h9i', msg: 'Fix mobile layout' }
];
console.log('Project history (newest last):');
log.forEach(c => console.log(' ' + c.hash + ' ' + c.msg));
console.log('\nEach hash is an ID you can return to.');Branching to Experiment
Want to try a redesign without risking your working app? Make a branch.
git branch new-design— create the branchgit checkout new-design— switch to it
Now you're working in a parallel copy. Your main version is frozen and safe. Build wild ideas here.
Modern shortcut: git checkout -b new-design creates and switches in one step. (Your AI knows all these.)
Merging Back In
When your experiment works, you bring it into your main version with a merge.
You switch back to your main branch and merge the experiment in. If something conflicts, AI is excellent at resolving it. Here's a prompt for the whole flow:
I created a branch called `new-design`, tested it, and it works great.
Give me the exact commands to:
1. Switch back to my main branch
2. Merge `new-design` into it
If there's a merge conflict, tell me how to spot it and what to do.Connecting to GitHub (push)
Push uploads your commits to GitHub so they're backed up online and shareable.
The easiest path: in Cursor or VS Code, click "Publish to GitHub." It creates the online repo and pushes for you.
If you prefer the terminal, your AI will give you the git remote add and git push commands. Once connected, future pushes are a single click or git push.
The .gitignore File
Some files should NOT be saved to Git — like secret API keys or huge auto-generated folders (node_modules).
A .gitignore file lists what Git should skip. This keeps your repo clean and your secrets safe.
Don't hand-write it — ask AI. A solid prompt:
Create a .gitignore file for a beginner web project.
Make sure it ignores node_modules, .env files with secrets,
and any OS junk files like .DS_Store. Explain why each
entry should be ignored, briefly.Your Repeatable Workflow
Here's the loop you'll use every single day as a vibe coder:
- Build a small feature with AI
- Test it — does it work?
- Stage and commit with a clear message
- For risky ideas, work on a branch first
- Push to GitHub to back everything up
Repeat. This rhythm keeps your project safe, organized, and always recoverable — no memorization required.
Quick Check
Let's check your grasp of the core Git flow.
Recap & What's Next
You can now run the full Git basics — with AI writing the commands:
- init starts tracking a project (once)
- stage + commit saves a snapshot with a message
- branch lets you experiment safely, merge brings it back
- push backs everything up on GitHub
- .gitignore keeps secrets and junk out
Next lesson: Letting AI Write Commit Messages — get a clean, professional history with almost no effort.
คำถามที่พบบ่อย
บทเรียน “พื้นฐาน Git พร้อมผู้ช่วยปัญญาประดิษฐ์” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “พื้นฐาน Git พร้อมผู้ช่วยปัญญาประดิษฐ์” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Vibe Coding ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Vibe Coding มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “พื้นฐาน Git พร้อมผู้ช่วยปัญญาประดิษฐ์”
คอมมิต สร้างสาขา และพุช โดยมีคำแนะนำจากปัญญาประดิษฐ์ คุณปฏิบัติ Vibe Coding ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Vibe Coding หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Vibe Coding บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน
บทเรียน “พื้นฐาน Git พร้อมผู้ช่วยปัญญาประดิษฐ์” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Vibe Coding นี้ได้ไหม
ได้ บทเรียน Vibe Coding ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- เหตุใดการควบคุมเวอร์ชันจึงสำคัญ
- พื้นฐาน Git พร้อมผู้ช่วยปัญญาประดิษฐ์
- ให้ปัญญาประดิษฐ์เขียนข้อความคอมมิต
- การย้อนคืนข้อผิดพลาดอย่างปลอดภัย