Reflog สำหรับการกู้คืน
ค้นพบ `git reflog` ซึ่งเป็นกลไกสำรองสำหรับกู้คืนคอมมิต สาขา หรือการรีเซ็ตที่เผลอทำหาย
Reflog สำหรับการกู้คืน เป็นบทเรียน Git Advanced: Monorepo, Submodules & Workflows ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Git Advanced: Monorepo, Submodules & Workflows และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Git Advanced: Monorepo, Submodules & Workflows มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Your Git Safety Net
git reflog is a journal of every move your HEAD makes — commit, checkout, merge, rebase, reset. It's a powerful safety net for recovering lost work.
Git's Head & Reference Logs
HEAD points to your current position, and the reflog records everywhere it's been. It lives locally on your machine — not in the shared repo history.
Viewing Your Reflog
Run git reflog to see each action indexed as HEAD@{0}, HEAD@{1}, and so on — with the commit hash, the move, and a timestamp.
git reflogDeciphering Reflog Output
Read reflog output as a stack: HEAD@{0} is your current state, HEAD@{1} the one before it. Each entry marks where HEAD changed.
Recovering from a Hard Reset
Accidentally ran git reset --hard HEAD~2? Don't panic — those commits aren't gone, just unreachable. The reflog still remembers where HEAD was before the reset.
Using Reflog to Undo Resets
Find the commit before your bad reset in git reflog, then recover it with git reset --hard <hash> — or use the index directly, like HEAD@{2}.
Rescuing a Deleted Branch
Deleted a branch with git branch -D? Its commits still live in your reflog, since HEAD's movements onto that branch were all recorded.
Recreating a Lost Branch
Find the deleted branch's last commit in the reflog, then recreate it: git branch my-feature <hash>. Check it out and you're back in business.
Reflog Expiration
Reflog entries don't last forever: reachable ones expire after 90 days, unreachable ones after 30. It's a safety net, not a backup — always push important work.
Reflog Recovery Quiz
You accidentally ran git reset --hard HEAD~3 and lost your last three commits. You check git reflog and see:
a1b2c3d HEAD@{0}: reset: moving to HEAD~3
e4f5g6h HEAD@{1}: commit: Final bug fix
f7e8d9c HEAD@{2}: commit: Implement new feature
i7j8k9l HEAD@{3}: commit: Initial setupWhich command would restore your repository to the state before the reset, bringing back "Final bug fix" and "Implement new feature"?
Reflog: Your Git Lifesaver
Recap: git reflog logs everywhere HEAD has been, your first defense against bad resets and lost branches. Recover with git reset --hard HEAD@{n} — but it does expire.
คำถามที่พบบ่อย
บทเรียน “Reflog สำหรับการกู้คืน” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “Reflog สำหรับการกู้คืน” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Git Advanced: Monorepo, Submodules & Workflows ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Git Advanced: Monorepo, Submodules & Workflows มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “Reflog สำหรับการกู้คืน”
ค้นพบ `git reflog` ซึ่งเป็นกลไกสำรองสำหรับกู้คืนคอมมิต สาขา หรือการรีเซ็ตที่เผลอทำหาย คุณปฏิบัติ Git Advanced: Monorepo, Submodules & Workflows ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Git Advanced: Monorepo, Submodules & Workflows หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Git Advanced: Monorepo, Submodules & Workflows บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน
บทเรียน “Reflog สำหรับการกู้คืน” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Git Advanced: Monorepo, Submodules & Workflows นี้ได้ไหม
ได้ บทเรียน Git Advanced: Monorepo, Submodules & Workflows ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- การรีเบสแบบโต้ตอบและการแก้ไขคอมมิต
- การเก็บและเลือกนำการเปลี่ยนแปลงมาใช้
- Reflog สำหรับการกู้คืน
- Bisect: ตามหาคอมมิตที่มีปัญหา