สรุปและแบบฝึกหัด
ประเด็นสำคัญ
- คือ จุดเซฟสำหรับโปรเจกต์ของคุณ — ไทม์ไลน์เต็มรูปแบบที่คุณสามารถย้อนกลับไปได้ ซึ่งเป็นสิ่งที่ทำให้คุณปล่อย AI ทำงานได้โดยไม่ต้องกลัว
- จังหวะหลักคือ
add→commit→push: stage การเปลี่ยนแปลงของคุณ บันทึกมันเป็น พร้อมข้อความที่ชัดเจน แล้วส่งขึ้นไปยัง GitHub เพื่อสำรองข้อมูลและแชร์ - สร้าง ก่อนทำอะไรใหญ่ ๆ และ อ่าน diff ก่อนทุก commit — นั่นคือวิธีที่คุณจับได้ว่า AI ลบบางอย่างที่ไม่ควรลบ
.gitignoreช่วยกันความลับ (เช่น.env) และขยะ (เช่นnode_modules/) ไม่ให้เข้าไปอยู่ในประวัติของคุณ ความลับที่ถูก commit ขึ้น GitHub จะรั่วไหลตลอดไป แม้ว่าคุณจะลบมันออกในภายหลัง- คุณให้ AI รันคำสั่งได้ แต่คุณยังคงรับผิดชอบในการเข้าใจว่าแต่ละคำสั่งทำอะไร โดยเฉพาะคำสั่งที่ทำลายล้าง อย่างเช่น
reset --hard
ลองทำดู
สร้างโฟลเดอร์ใหม่เอี่ยมแล้วรันวงจรทั้งหมดด้วยตัวเอง ด้วยมือ: git init สร้าง .gitignore ที่มี .env อยู่ในนั้น เพิ่มไฟล์ notes.txt ง่าย ๆ จากนั้น git add . และ git commit -m "Initial commit" ตอนนี้รัน git log --oneline เพื่อดูจุดเซฟของคุณ แก้ไขไฟล์ แล้วรัน git diff เพื่อดู Git แสดงให้คุณเห็นแน่ชัดว่าอะไรเปลี่ยนไป คุณเพิ่งใช้นิสัยหลักทุกอย่างในบทนี้กับโปรเจกต์ที่ไม่มีอะไรผิดพลาดได้เลย
คำสั่งประจำบท
I'm learning Git as a beginner and I want you to run the commands for me,
but teach as you go. For the task below:
<describe what you want to do — e.g. "save my current work" or "try a risky change safely">
- Tell me which Git commands you'll run and what each one does in plain English.
- If anything is destructive (reset --hard, force-push, deleting a branch),
warn me clearly and explain what I'd lose before doing it.
- Before any commit, show me the diff and summarize what changed.
- Remind me if there's anything in the change that shouldn't be public (secrets, keys).